ideo/otpauth

Provides necessary processing for TOTP.

Maintainers

Details

github.com/aideo/otpauth

Source

Issues

Installs: 16

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/ideo/otpauth

0.1 2017-11-26 19:44 UTC

This package is not auto-updated.

Last update: 2025-10-18 20:47:35 UTC


README

Build Status

Provides necessary processing for TOTP.

For pin generation and authentication, it is based on the implementation of google-authenticator.

Usage

Generation of QR code for TOTP compatible applications.

$keyGenerator = new KeyGenerator();
$qrCodeGenerator = new QrCodeGenerator();

// Generate keys randomly, save this key in association with the target account.
$keyBytes = $keyGenerator->generateRandom(10);

$qrDataUri = $qrCodeGenerator->getQrCodeDataUri($keyBytes, 'sample@foo.bar', 'Sample');

Authentication using pin.

// It reads the key of the target account and compares it with the input pin.
$passcodeGenerator = new PasscodeGenerator(new HMacSigner($keyBytes));
$counter = new TotpCounter();
$time = time();

$valid = $passcodeGenerator->verifyTimeoutCode($pin, $counter->getValueAtTime($time));