1. Go to this page and download the library: Download khooz/oath library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
khooz / oath example snippets
$otp = new Oath();
$otp->secret; // The secret used for code generation in Base32; default is randomly generated SHA1 hash
$otp->account = "john_doe"; // The account name used in combination of issuer and domain for making otpauth uri
$otp->type; // Either "hotp" or "totp"; default is totp
$otp->counter; // The current value of counter for HOTP; or null if type is "totp"; default is 0
$otp->period; // The period of code mutation for TOTP; null if type is "hotp"; default is 30
$otp->generate(); // generates new code based on current parameter
$otp->check($code); // checks current code with the provided code (integer). Returns true if both are the same.
Oath::config(
$issuer, // Default issuer as specified in standard
$domain, // Default domain as specified in standard
$period, // Default period for totp, must be greated than 0
$digits, // Default number of digits per code as specified in standard
$initial_counter, // Default initial counter for hotp, must be positive
$length, // Default length for generated messages and salts for cryptographically secure secret generation
$iterations, // Default hash iterations for cryptographically secure secret generation
$type, // Default type as specified in standard, either 'hotp' or 'totp'
$algorithm, // Default algorithm as specified in standard, it can use all hmac algorithms available to the system if strict mode is off
$qrURI, // Default issuer as specified in standard
$strict // Default strict mode. If true, only values specified in the standard can be used. By default it is true.
);
$oath->generate(-1); // Generates the last expired code
$oath->generate(0); // Generates the current valid code
$oath->generate(1); // Generates the next code in codes sequence
$oath->check(123456, 0, 1); // Checks 123456 against the last expired, current, and next codes; gives user a 90s leeway in a 30s-period TOTP
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.