Open isarjanfaza opened 6 years ago
In PHP 7, MCrypt is deprecated... A workaround is to use openssl_* instead :
function encrypt2($str) {
$encrypted = openssl_encrypt($str, 'aes-128-cbc', KEY_SERVICE, OPENSSL_RAW_DATA, IV_SERVICE);
return bin2hex($encrypted);
}
function decrypt2($code) {
$code = $this->hex2bin($code);
$decrypted = openssl_decrypt($code, 'aes-128-cbc', KEY_SERVICE, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, IV_SERVICE);
return trim($decrypted);
}
Thanks @Goufalite for the suggestion.
Would you like to create a pull request to contribute with the code?
I have to check something with the ZERO_PADDING option which messes with the result, then I'll make the pull request
hi @Goufalite how to set java class for this code?
Look at the code tab on top, there's a Java MCrypt class.
I still have some leading NULL characters at the beginning so some trim might be in order to process the strings.
i used that Java class but the results were not the same as your code results
What were the results?
hi when use php version 7 not work and get error {main} thrown in MCrypt.php on line 11
please check this bug
thanks