totp

A PHP library for TOTP support in PHP 7.2+.

MIT License

Downloads
81
Stars
4
Committers
1

TOTP PHP 7.4+ Build Status PHPStan Coverage Status Packagist

A PHP library for generating one-time passwords according to RFC-6238 for time-based OTP generation.

This library is compatible with Google Authenticator apps available for Android and iPhone.

Quick Start

Use Composer to add ericmann/totp to your project.

require __DIR__ . '/vendor/autoload.php';

// Create a new, random token
$token = new EAMann\TOTP\Key();

// Import a known token
$raw = '...';
$token = EAMann\TOTP\Key::import($raw);

// Validate an OTP against a token
if (EAMann\TOTP\is_valid_auth_code($token, $otp)) {
  // ...
}