@@ -70,9 +70,9 @@ |
||
70 | 70 | */ |
71 | 71 | private static function cost(int $cost): int |
72 | 72 | { |
73 | - if ($cost < 0 || $cost > \pow(2, 32)) { |
|
74 | - throw new \InvalidArgumentException("Hashing cost parameter must between 0 and 2^32"); |
|
75 | - } |
|
73 | + if ($cost < 0 || $cost > \pow(2, 32)) { |
|
74 | + throw new \InvalidArgumentException("Hashing cost parameter must between 0 and 2^32"); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | return $cost; |
78 | 78 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $cost = \unpack('L*', $itr ^ \hash_hmac(static::CHKSUM, $ivr, $pass, true))[1]; |
58 | 58 | |
59 | 59 | // Derive key from password |
60 | - $key = \hash_pbkdf2(static::CHKSUM, ($pass . static::CIPHER), $ivr, $cost, 0, true); |
|
60 | + $key = \hash_pbkdf2(static::CHKSUM, ($pass.static::CIPHER), $ivr, $cost, 0, true); |
|
61 | 61 | |
62 | 62 | // Calculate verification checksum |
63 | 63 | $chk = \hash_hmac(static::CHKSUM, $msg, $key, true); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $ivr = \random_bytes(OpensslWrapper::ivsize(static::CIPHER)); |
86 | 86 | |
87 | 87 | // Derive key from password |
88 | - $key = \hash_pbkdf2(static::CHKSUM, ($pass . static::CIPHER), $ivr, $cost, 0, true); |
|
88 | + $key = \hash_pbkdf2(static::CHKSUM, ($pass.static::CIPHER), $ivr, $cost, 0, true); |
|
89 | 89 | |
90 | 90 | // Encrypt the plaintext |
91 | 91 | $msg = OpensslWrapper::encrypt($data, static::CIPHER, $key, $ivr); |
@@ -97,6 +97,6 @@ discard block |
||
97 | 97 | $chk = \hash_hmac(static::CHKSUM, $msg, $key, true); |
98 | 98 | |
99 | 99 | // Return iv + checksum + iterations + cyphertext |
100 | - return $ivr . $chk . $itr . $msg; |
|
100 | + return $ivr.$chk.$itr.$msg; |
|
101 | 101 | } |
102 | 102 | } |