Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6807713

Browse files
committed
Opcache Optimisations for Argon2iPasswordEncoder
1 parent dbf7b62 commit 6807713

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class Argon2iPasswordEncoder extends BasePasswordEncoder implements SelfSaltingE
2222
{
2323
public static function isSupported()
2424
{
25-
return function_exists('sodium_crypto_pwhash_str')
26-
|| extension_loaded('libsodium')
27-
|| (\PHP_VERSION_ID >= 70200 && defined('PASSWORD_ARGON2I'));
25+
return (\PHP_VERSION_ID >= 70200 && \defined('PASSWORD_ARGON2I'))
26+
|| \function_exists('sodium_crypto_pwhash_str')
27+
|| \extension_loaded('libsodium');
2828
}
2929

3030
/**
@@ -36,13 +36,13 @@ public function encodePassword($raw, $salt)
3636
throw new BadCredentialsException('Invalid password.');
3737
}
3838

39-
if (\PHP_VERSION_ID >= 70200 && defined('PASSWORD_ARGON2I')) {
39+
if (\PHP_VERSION_ID >= 70200 && \defined('PASSWORD_ARGON2I')) {
4040
return $this->encodePasswordNative($raw);
4141
}
42-
if (function_exists('sodium_crypto_pwhash_str')) {
42+
if (\function_exists('sodium_crypto_pwhash_str')) {
4343
return $this->encodePasswordSodiumFunction($raw);
4444
}
45-
if (extension_loaded('libsodium')) {
45+
if (\extension_loaded('libsodium')) {
4646
return $this->encodePasswordSodiumExtension($raw);
4747
}
4848

@@ -54,16 +54,16 @@ public function encodePassword($raw, $salt)
5454
*/
5555
public function isPasswordValid($encoded, $raw, $salt)
5656
{
57-
if (\PHP_VERSION_ID >= 70200 && defined('PASSWORD_ARGON2I')) {
57+
if (\PHP_VERSION_ID >= 70200 && \defined('PASSWORD_ARGON2I')) {
5858
return !$this->isPasswordTooLong($raw) && password_verify($raw, $encoded);
5959
}
60-
if (function_exists('sodium_crypto_pwhash_str_verify')) {
60+
if (\function_exists('sodium_crypto_pwhash_str_verify')) {
6161
$valid = !$this->isPasswordTooLong($raw) && \sodium_crypto_pwhash_str_verify($encoded, $raw);
6262
\sodium_memzero($raw);
6363

6464
return $valid;
6565
}
66-
if (extension_loaded('libsodium')) {
66+
if (\extension_loaded('libsodium')) {
6767
$valid = !$this->isPasswordTooLong($raw) && \Sodium\crypto_pwhash_str_verify($encoded, $raw);
6868
\Sodium\memzero($raw);
6969

0 commit comments

Comments
 (0)