php openssl_の使用encryptにおけるAES-128-ECB暗号解読
3326 ワード
$key = ‘Hl2018@1212’; //
/**
* @param string $string
* @param string $key
* @return string
*/
function encrypt($string, $key)
{
// openssl_encrypt Mcrypt, , 16
$data = openssl_encrypt($string, 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
$data = strtolower(bin2hex($data));
return $data;
}
/**
* @param string $string
* @param string $key
* @return string
*/
function decrypt($string, $key)
{
$decrypted = openssl_decrypt(hex2bin($string), 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
return $decrypted;
}