jakobo / hotp-php
HOTP simplifies One Time Password systems for PHP Authentication
Requires
- php: >=7.2
Requires (Dev)
- ockcyp/covers-validator: 1.3.3
- php-parallel-lint/php-console-highlighter: 0.5
- php-parallel-lint/php-parallel-lint: 1.2.0
- phpunit/phpunit: ^8.5.13||^9.5.0
This package is not auto-updated.
Last update: 2024-11-20 00:02:25 UTC
README
What is HOTP: HOTP is a class that simplifies One Time Password systems for PHP Authentication. The HOTP/TOTP Algorithms have been around for a bit, so this is a straightforward class to meet the test vector requirements.
What works with HOTP/TOTP: It's been tested to the test vectors, and I've verified the time-sync hashes against the following:
- Android: Mobile-OTP
- iPhone: OATH Token
Why would I use this: Who wouldn't love a simple drop-in class for HMAC Based One Time Passwords? It's a great extra layer of security (creating two-factor auth) and it's pretty darn zippy.
Okay you sold me. Give me some docs:
use jakobo\HOTP\HOTP; // event based $result = HOTP::generateByCounter( $key, $counter ); // time based within a "window" of time $result = HOTP::generateByTime( $key, $window ); // same as generateByTime, but for $min windows before and $max windows after $result = HOTP::generateByTimeWindow( $key, $window, $min, $max );
with $result
, you can do all sorts of neat things...
$result->toString(); $result->toHex(); $result->toDec(); // how many digits in your OTP? $result->toHotp( $length );