All,
Anybody ported MATE to PHP 7.2.
It seems the mcrypt module is deprecated in 7.2
Regards
Karel
public function encryptData($message) {
$key = 'blabla';
if (mb_strlen($key, '8bit') !== 32) {
throw new Exception("Needs a 256-bit key!");
}
$ivsize = openssl_cipher_iv_length('aes-256-cbc');
$iv = openssl_random_pseudo_bytes($ivsize);
$ciphertext = openssl_encrypt(
$message,
'aes-256-cbc',
$key,
OPENSSL_RAW_DATA,
$iv
);
return $iv . $ciphertext;
}
public function decryptData($message) {
$key = 'blabla';
if (mb_strlen($key, '8bit') !== 32) {
throw new Exception("Needs a 256-bit key!");
}
$ivsize = openssl_cipher_iv_length('aes-256-cbc');
$iv = mb_substr($message, 0, $ivsize, '8bit');
$ciphertext = mb_substr($message, $ivsize, null, '8bit');
return openssl_decrypt(
$ciphertext,
'aes-256-cbc',
$key,
OPENSSL_RAW_DATA,
$iv
);
}
Users browsing this forum: No registered users and 3 guests