| 1 |
HOTP - PHP Based HMAC One Time Passwords |
| 2 |
======================================== |
| 3 |
|
| 4 |
**What is HOTP**: |
| 5 |
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. |
| 6 |
|
| 7 |
**What works with HOTP/TOTP**: |
| 8 |
It's been tested to the test vectors, and I've verified the time-sync hashes against the following: |
| 9 |
|
| 10 |
* Android: Mobile-OTP |
| 11 |
* iPhone: OATH Token |
| 12 |
|
| 13 |
**Why would I use this**: |
| 14 |
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. |
| 15 |
|
| 16 |
**Okay you sold me. Give me some docs**: |
| 17 |
|
| 18 |
```php |
| 19 |
use jakobo\HOTP\HOTP; |
| 20 |
|
| 21 |
// event based |
| 22 |
$result = HOTP::generateByCounter( $key, $counter ); |
| 23 |
|
| 24 |
// time based within a "window" of time |
| 25 |
$result = HOTP::generateByTime( $key, $window ); |
| 26 |
|
| 27 |
// same as generateByTime, but for $min windows before and $max windows after |
| 28 |
$result = HOTP::generateByTimeWindow( $key, $window, $min, $max ); |
| 29 |
``` |
| 30 |
|
| 31 |
with `$result`, you can do all sorts of neat things... |
| 32 |
|
| 33 |
```php |
| 34 |
$result->toString(); |
| 35 |
|
| 36 |
$result->toHex(); |
| 37 |
|
| 38 |
$result->doDec(); |
| 39 |
|
| 40 |
// how many digits in your OTP? |
| 41 |
$result->toHotp( $length ); |
| 42 |
``` |