base64_encode() encrypted binary data
Этот коммит содержится в:
родитель
b162b0ffc4
Коммит
56b69fc303
|
@ -185,11 +185,12 @@ class Helper
|
|||
return false;
|
||||
}
|
||||
// Split initialisation vector and encrypted data.
|
||||
$iv = substr($encrypted, 0, openssl_cipher_iv_length(self::$cipherAlgorithm));
|
||||
$data = substr($encrypted, openssl_cipher_iv_length(self::$cipherAlgorithm));
|
||||
$binary = base64_decode($encrypted);
|
||||
$iv = substr($binary, 0, openssl_cipher_iv_length(self::$cipherAlgorithm));
|
||||
$data = substr($binary, openssl_cipher_iv_length(self::$cipherAlgorithm));
|
||||
$key = openssl_digest($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], self::$hashAlgorithm, true);
|
||||
// Decrypt data.
|
||||
$decrypted = openssl_decrypt($data, self::$cipherAlgorithm, $key, 0, $iv);
|
||||
$decrypted = openssl_decrypt($data, self::$cipherAlgorithm, $key, OPENSSL_RAW_DATA, $iv);
|
||||
return $decrypted;
|
||||
}
|
||||
|
||||
|
@ -282,10 +283,10 @@ class Helper
|
|||
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length(self::$cipherAlgorithm));
|
||||
$key = openssl_digest($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], self::$hashAlgorithm, true);
|
||||
// Encrypt data.
|
||||
$encrypted = openssl_encrypt($string, self::$cipherAlgorithm, $key, 0, $iv);
|
||||
$encrypted = openssl_encrypt($string, self::$cipherAlgorithm, $key, OPENSSL_RAW_DATA, $iv);
|
||||
// Merge initialisation vector and encrypted data.
|
||||
if ($encrypted !== false) {
|
||||
$encrypted = $iv . $encrypted;
|
||||
$encrypted = base64_encode($iv . $encrypted);
|
||||
}
|
||||
return $encrypted;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче