当前位置:实例文章 » PHP实例» [文章]PHP解密CryptoJS.AES.encrypt 不带IV

PHP解密CryptoJS.AES.encrypt 不带IV

发布人:shili8 发布时间:2023-01-30 05:40 阅读次数:26

$ctOpenSSL = base64_decode("U2FsdGVkX1BUVUBB7Noz3lFOgEu9Z6qlFe6iGZyKU4ysOx2rdzEcw=");

$salt = substr($ctOpenSSL, 8, 8);

$ciphertext = substr($ctOpenSSL, 16);

// Derive key and IV

$keyIv = $this->EVP_BytesToKey($salt, "87R6W73IO8C43P32");

$key = substr($keyIv, 0, 32);

$iv = substr($keyIv, 32, 16);

// Decrypt

$decrypted = openssl_decrypt($ciphertext, "aes-256-cbc", $key, OPENSSL_RAW_DATA, $iv);

public function EVP_BytesToKey($salt, $password) {

$bytes = '';

$last = '';

while(strlen($bytes) < 48) {

$last = hash('md5', $last . $password . $salt, true);

$bytes.= $last;

}

return $bytes;

}

相关标签:

免责声明

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱290110527@qq.com删除。

其他信息

其他资源

Top