Skip to content

Commit 1ebd0f3

Browse files
committed
CS: Pre incrementation/decrementation should be used if possible
1 parent 8bd591e commit 1ebd0f3

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

Encoder/MessageDigestPasswordEncoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function encodePassword($raw, $salt)
5555
$digest = hash($this->algorithm, $salted, true);
5656

5757
// "stretch" hash
58-
for ($i = 1; $i < $this->iterations; $i++) {
58+
for ($i = 1; $i < $this->iterations; ++$i) {
5959
$digest = hash($this->algorithm, $digest.$salted, true);
6060
}
6161

Encoder/Pbkdf2PasswordEncoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ private function hashPbkdf2($algorithm, $password, $salt, $iterations, $length =
8787
$blocks = ceil($length / strlen(hash($algorithm, null, true)));
8888
$digest = '';
8989

90-
for ($i = 1; $i <= $blocks; $i++) {
90+
for ($i = 1; $i <= $blocks; ++$i) {
9191
$ib = $block = hash_hmac($algorithm, $salt.pack('N', $i), $password, true);
9292

9393
// Iterations
94-
for ($j = 1; $j < $iterations; $j++) {
94+
for ($j = 1; $j < $iterations; ++$j) {
9595
$ib ^= ($block = hash_hmac($algorithm, $block, $password, true));
9696
}
9797

Util/StringUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static function equals($knownString, $userInput)
6060

6161
$result = 0;
6262

63-
for ($i = 0; $i < $knownLen; $i++) {
63+
for ($i = 0; $i < $knownLen; ++$i) {
6464
$result |= (ord($knownString[$i]) ^ ord($userInput[$i]));
6565
}
6666

0 commit comments

Comments
 (0)