Skip to content

Commit

Permalink
Fixed Crypt test for PHP 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyklay committed May 28, 2018
1 parent 9c028d2 commit f7af03f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-3.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Added `Phalcon\Crypt::setHashAlgo` to set the name of hashing algorithm used to the calculating message digest [#13379](https://github.com/phalcon/cphalcon/issues/13379)
- Added `Phalcon\Crypt::getHashAlgo` to get the name of hashing algorithm used to the calculating message digest [#13379](https://github.com/phalcon/cphalcon/issues/13379)
- Added `Phalcon\Crypt::useSigning` to set if the calculating message digest must used (NOTE: This feature will be enabled by default in Phalcon 4.0.0) [#13379](https://github.com/phalcon/cphalcon/issues/13379)
- Added `Phalcon\Crypt::getAvailableHashAlgos` to get a list of registered hashing algorithms suitable for calculating message digest [#13379](https://github.com/phalcon/cphalcon/issues/13379)
- Added `Phalcon\Crypt::__construct` so now the cipher can be set at object construction and the calculating message digest can be enabled without the need to call `setCipher` or `useSigning` explicitly [#13379](https://github.com/phalcon/cphalcon/issues/13379)
- Added `Phalcon\Crypt\Mismatch`. Exceptions thrown in `Phalcon\Crypt` will use this class [#13379](https://github.com/phalcon/cphalcon/issues/13379)
- Added `Phalcon\Http\Cookie::setSignKey` to set sign key used to generate a message authentication code (eg. message digest)
Expand Down
4 changes: 3 additions & 1 deletion phalcon/crypt.zep
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ class Crypt implements CryptInterface
}

/**
* Check the text's message digest using the HMAC method.
* Checkson the decrypted's message digest using the HMAC method.
*/
if hash_hmac(hashAlgo, decrypted, decryptKey, true) !== hash {
throw new Mismatch("Hash does not match.");
Expand Down Expand Up @@ -507,6 +507,8 @@ class Crypt implements CryptInterface

/**
* Decrypt a text that is coded as a base64 string.
*
* @throws \Phalcon\Crypt\Mismatch
*/
public function decryptBase64(string! text, key = null, boolean! safe = false) -> string
{
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/CryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function () {
$encrypted = $crypt->encrypt($text);
$decrypted = $crypt->decrypt($encrypted);

expect(hash_equals($text, $decrypted))->true();
expect($text)->equals($decrypted);
}
);
}
Expand Down

0 comments on commit f7af03f

Please sign in to comment.