diff --git a/src/Helpers/TextHelper.php b/src/Helpers/TextHelper.php index ff108db9..7e9ec8a1 100644 --- a/src/Helpers/TextHelper.php +++ b/src/Helpers/TextHelper.php @@ -195,7 +195,11 @@ class TextHelper $hash = base64_decode($hash); $alg = MCRYPT_RIJNDAEL_256; $mode = MCRYPT_MODE_CBC; - return trim(mcrypt_decrypt($alg, $salt, $hash, $mode, $iv)); + $ret = mcrypt_decrypt($alg, $salt, $hash, $mode, $iv); + $pos = strpos($ret, "\0"); + if ($pos !== false) + $ret = substr($ret, 0, $pos); + return $ret; } catch (Exception $e) { diff --git a/src/SimpleException.php b/src/SimpleException.php index 8ca34ef3..99baa0ad 100644 --- a/src/SimpleException.php +++ b/src/SimpleException.php @@ -3,6 +3,8 @@ class SimpleException extends Exception { public function __construct() { - parent::__construct(call_user_func_array('sprintf', func_get_args())); + parent::__construct(func_num_args() > 1 + ? call_user_func_array('sprintf', func_get_args()) + : func_get_args()[0]); } } diff --git a/tests/MiscTest.php b/tests/MiscTest.php new file mode 100644 index 00000000..47795911 --- /dev/null +++ b/tests/MiscTest.php @@ -0,0 +1,19 @@ +assert->areEqual($text, TextHelper::decrypt(TextHelper::encrypt($text))); + } + } +}