我的mcrypt代码有问题:
<?php
class Encryption {
public function encrypt($value){
$key = 'dfMsnopnM:kNas;ljn46tgskjdnkdnfn';
if (!$value) {
return false;
}
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$encrypted_string = trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $value, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
return $encrypted_string;
}
public function decrypt($value){
$key = 'dfMsnopnM:kNas;ljn46tgskjdnkdnfn';
if (!$value) {
return false;
}
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$decrypted_string = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($value), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)));
return $decrypted_string;
}
}?>
只有一些字符串以错误的方式解密。我找不到这个字符串之间的任何匹配。只有他们都保存在chrome自动填充中。这可能是错误的原因吗?或者你可以在Encryption
课程中找到一些错误的东西吗?