php - 为什么 Openssl 使用 openssl_decrypt 函数抛出错误?
问题描述
我收到此错误,但我不知道为什么。
openssl_decrypt(): IV 传递只有 8 字节长,密码期望 IV 正好 16 字节,用 \0 填充
我认为这是一个长度错误,但不确定。
功能
public static function decrypt($ciphertext) {
$iv_size = openssl_cipher_iv_length('AES-128-CBC');
$iv = substr(base64_decode($ciphertext), 0, $iv_size);
$ciphertext = substr(base64_decode($ciphertext), $iv_size);
$dec = openssl_decrypt($ciphertext, 'AES-128-CBC', self::key(), OPENSSL_RAW_DATA, $iv);
return $dec;
}
解决方案
推荐阅读
- r - R - 从序列数据构建新变量
- python - 无法获得 Python 脚本的正确退出值,正在远程机器上运行
- excel - 将命名范围扩展 1 行
- c# - 在另一个项目中使用自定义 C# 类库
- javascript - 尽管它存在于 DB 中,但 Promise 返回 null 值
- javascript - 根据子组件的数据计算父状态:ReactJS
- regex - 匹配两个条件中的第一个
- apache - ZooKeeper 在网络中断后显示不存在的节点
- python - Pattern-lib : 哪个词是句子的 ROOT(dependency parsing)?
- adobe - 数组的javascript多少和分钟