Skip to content

Commit 876ed96

Browse files
committed
🚿
1 parent 040318f commit 876ed96

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ via terminal: `composer require chillerlan/php-authenticator`
3737
}
3838
}
3939
```
40-
Note: replace `dev-main` with a [version constraint](https://getcomposer.org/doc/articles/versions.md#writing-version-constraints), e.g. `^5.0` - see [releases](https://github.com/chillerlan/php-authenticator/releases) for valid versions
40+
Note: replace `dev-v5.x` with a [version constraint](https://getcomposer.org/doc/articles/versions.md#writing-version-constraints), e.g. `^5.0` - see [releases](https://github.com/chillerlan/php-authenticator/releases) for valid versions
4141

4242
Profit!
4343

4444
## Usage
4545
### Create a secret
4646
The secret is usually being created once during the activation process in a user control panel.
4747
So all you need to do there is to display it to the user in a convenient way -
48-
as a text string and QR code for example - and save it somewhere with the user data.
48+
as a text string and [QR code](https://github.com/chillerlan/php-qrcode/blob/9964cf8ff1ad90d17c360bd320cf18e16cd59829/examples/authenticator.php) for example - and save it somewhere with the user data.
4949
```php
5050
use chillerlan\Authenticator\{Authenticator, AuthenticatorOptions};
5151

src/AuthenticatorOptionsTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ protected function set_adjacent(int $adjacent):void{
167167
* @throws \InvalidArgumentException
168168
*/
169169
protected function set_secret_length(int $secret_length):void{
170-
// ~ 80 to 640 bits
170+
171171
if($secret_length < 16 || $secret_length > 1024){
172172
throw new InvalidArgumentException('Invalid secret length: '.$secret_length);
173173
}

src/Authenticators/HOTP.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public function getHMAC(int $counter):string{
4444
}
4545
// @codeCoverageIgnoreStart
4646
$data = (PHP_INT_SIZE < 8)
47+
// 32-bit
4748
? "\x00\x00\x00\x00".pack('N', $counter)
49+
// 64-bit
4850
: pack('J', $counter);
4951
// @codeCoverageIgnoreEnd
5052
return hash_hmac($this->options->algorithm, $data, $this->secret, true);
@@ -61,8 +63,8 @@ public function getCode(#[SensitiveParameter] string $hmac):int{
6163
}
6264

6365
$b = ($data[strlen($hmac)] & 0xF);
64-
// phpcs:ignore
65-
return (($data[$b + 1] & 0x7F) << 24) | ($data[$b + 2] << 16) | ($data[$b + 3] << 8) | $data[$b + 4];
66+
67+
return (($data[$b + 1] & 0x7F) << 24) | ($data[$b + 2] << 16) | ($data[$b + 3] << 8) | $data[$b + 4]; // phpcs:ignore
6668
}
6769

6870
/**

0 commit comments

Comments
 (0)