Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

shiwildy/PHPTOTP

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHPTOTP

A simple TOTP library for PHP

Installation

composer require shiwildy/phptotp

Example

<?php

    require "vendor/autoload.php";
    use ShiWildy\phptotp;

    // Setup phptotp instance
    $phptotp = new phptotp();
    
    // Generate Secret Key
    $secret = $phptotp->getSecret();
    echo "Secret Key: " . $secret . PHP_EOL;
    
    // Generate Current auth code
    $auth = $phptotp->getAuth($secret);
    echo  "Current Auth Code:" . $auth . PHP_EOL;
    
    // Verify Auth code with secret key
    $verify = $phptotp->verify($auth, $secret);
    if ($verify === true) {
        echo "Verify status: Correct" . PHP_EOL;
    } else {
        echo "Verify status: Incorrect" . PHP_EOL;
    }
    
    // Generate TOTP Link
    $qrcodelink = $phptotp->getQRCodeUrl("ismy@email.com", "MyApp", $secret);
    echo "Importable Link for QR: "  . $qrcodelink . PHP_EOL;
?>

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.

License

This project licensed under The MIT License

Morty Proxy This is a proxified and sanitized view of the page, visit original site.