1 | <?php |
||
14 | trait OathTrait |
||
15 | { |
||
16 | /** |
||
17 | * @var int the length of the time based one time password token generated. Defaults to 6. |
||
18 | */ |
||
19 | protected $tokenLength = 6; |
||
20 | |||
21 | /** |
||
22 | * Takes the secret key and the timestamp and returns the one time password. |
||
23 | * |
||
24 | * @param string $seed the secret key in binary form |
||
25 | * @param string $counter the time as returned by getTimestamp |
||
26 | * |
||
27 | * @return string |
||
28 | */ |
||
29 | protected function oathHotp(string $seed, string $counter): string |
||
37 | |||
38 | /** |
||
39 | * Extracts the OTP from the SHA1 hash. |
||
40 | * |
||
41 | * @param string $hash |
||
42 | * |
||
43 | * @return int |
||
44 | **/ |
||
45 | protected function oathTruncate(string $hash): int |
||
52 | } |
||
53 |