1 | <?php |
||
19 | class Encoder implements TotpEncoderInterface |
||
20 | { |
||
21 | use SecretValidationTrait; |
||
22 | |||
23 | /** |
||
24 | * Encoder constructor. |
||
25 | * |
||
26 | * @param SecretKeyValidator|null $secretKeyValidator |
||
27 | */ |
||
28 | public function __construct(SecretKeyValidator $secretKeyValidator = null) |
||
32 | |||
33 | /** |
||
34 | * @inheritdoc |
||
35 | */ |
||
36 | public function generateBase32RandomKey($length = 16, $prefix = '') |
||
45 | |||
46 | /** |
||
47 | * @inheritdoc |
||
48 | */ |
||
49 | public function toBase32($value) |
||
55 | |||
56 | /** |
||
57 | * @inheritdoc |
||
58 | */ |
||
59 | public function fromBase32($value) |
||
67 | |||
68 | /** |
||
69 | * Get a random number. |
||
70 | * |
||
71 | * @param $from |
||
72 | * @param $to |
||
73 | * |
||
74 | * @return int |
||
75 | */ |
||
76 | protected function getRandomNumber($from = 0, $to = 31) |
||
80 | |||
81 | /** |
||
82 | * Pad string with random base 32 chars. |
||
83 | * |
||
84 | * @param $string |
||
85 | * @param $length |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | private function strPadBase32($string, $length) |
||
97 | } |
||
98 |