@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | $hashingCost = $this->config->getSystemValue('hashingCost', null); |
81 | - if(!\is_null($hashingCost)) { |
|
81 | + if (!\is_null($hashingCost)) { |
|
82 | 82 | $this->options['cost'] = $hashingCost; |
83 | 83 | } |
84 | 84 | } |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function hash(string $message): string { |
95 | 95 | if (\defined('PASSWORD_ARGON2I')) { |
96 | - return 2 . '|' . password_hash($message, PASSWORD_ARGON2I, $this->options); |
|
96 | + return 2.'|'.password_hash($message, PASSWORD_ARGON2I, $this->options); |
|
97 | 97 | } else { |
98 | - return 1 . '|' . password_hash($message, PASSWORD_BCRYPT, $this->options); |
|
98 | + return 1.'|'.password_hash($message, PASSWORD_BCRYPT, $this->options); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function splitHash(string $prefixedHash) { |
108 | 108 | $explodedString = explode('|', $prefixedHash, 2); |
109 | - if(\count($explodedString) === 2) { |
|
110 | - if((int)$explodedString[0] > 0) { |
|
111 | - return ['version' => (int)$explodedString[0], 'hash' => $explodedString[1]]; |
|
109 | + if (\count($explodedString) === 2) { |
|
110 | + if ((int) $explodedString[0] > 0) { |
|
111 | + return ['version' => (int) $explodedString[0], 'hash' => $explodedString[1]]; |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | * @return bool Whether $hash is a valid hash of $message |
124 | 124 | */ |
125 | 125 | protected function legacyHashVerify($message, $hash, &$newHash = null): bool { |
126 | - if(empty($this->legacySalt)) { |
|
126 | + if (empty($this->legacySalt)) { |
|
127 | 127 | $this->legacySalt = $this->config->getSystemValue('passwordsalt', ''); |
128 | 128 | } |
129 | 129 | |
130 | 130 | // Verify whether it matches a legacy PHPass or SHA1 string |
131 | 131 | $hashLength = \strlen($hash); |
132 | - if(($hashLength === 60 && password_verify($message.$this->legacySalt, $hash)) || |
|
132 | + if (($hashLength === 60 && password_verify($message.$this->legacySalt, $hash)) || |
|
133 | 133 | ($hashLength === 40 && hash_equals($hash, sha1($message)))) { |
134 | 134 | $newHash = $this->hash($message); |
135 | 135 | return true; |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | * @return bool Whether $hash is a valid hash of $message |
147 | 147 | */ |
148 | 148 | protected function verifyHashV1(string $message, string $hash, &$newHash = null): bool { |
149 | - if(password_verify($message, $hash)) { |
|
149 | + if (password_verify($message, $hash)) { |
|
150 | 150 | $algo = PASSWORD_BCRYPT; |
151 | 151 | if (\defined('PASSWORD_ARGON2I')) { |
152 | 152 | $algo = PASSWORD_ARGON2I; |
153 | 153 | } |
154 | 154 | |
155 | - if(password_needs_rehash($hash, $algo, $this->options)) { |
|
155 | + if (password_needs_rehash($hash, $algo, $this->options)) { |
|
156 | 156 | $newHash = $this->hash($message); |
157 | 157 | } |
158 | 158 | return true; |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * @return bool Whether $hash is a valid hash of $message |
170 | 170 | */ |
171 | 171 | protected function verifyHashV2(string $message, string $hash, &$newHash = null) : bool { |
172 | - if(password_verify($message, $hash)) { |
|
173 | - if(password_needs_rehash($hash, PASSWORD_ARGON2I, $this->options)) { |
|
172 | + if (password_verify($message, $hash)) { |
|
173 | + if (password_needs_rehash($hash, PASSWORD_ARGON2I, $this->options)) { |
|
174 | 174 | $newHash = $this->hash($message); |
175 | 175 | } |
176 | 176 | return true; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | public function verify(string $message, string $hash, &$newHash = null): bool { |
189 | 189 | $splittedHash = $this->splitHash($hash); |
190 | 190 | |
191 | - if(isset($splittedHash['version'])) { |
|
191 | + if (isset($splittedHash['version'])) { |
|
192 | 192 | switch ($splittedHash['version']) { |
193 | 193 | case 2: |
194 | 194 | return $this->verifyHashV2($message, $splittedHash['hash'], $newHash); |