【发布时间】:2016-09-26 19:33:29
【问题描述】:
我想更改给定数据库的所有密码。所有这些密码都是用 DES CBC PKCS7 加密的,我有密钥和初始化向量。我使用下一个网页http://www.txtwizard.net/crypto 解密了一个密码,结果符合预期(使用选项 DES、CBC 和 PKCS7)。
键: RRZy0njZDzw=
iv: p/34qWLNYfg=
纯文本 123123
加密文本 x541kJ4KvJo=
但是当下一个用 PHP 编写的代码时,我无法复制结果:
<?php
$key = "RRZy0njZDzw=";
$iv = "p/34qWLNYfg=";
$data = "123123";
$cipher='DES-CBC';
var_dump(openssl_get_cipher_methods());
$encrypted = openssl_encrypt($data,$cipher, $key,OPENSSL_RAW_DATA,$iv);
echo base64_encode($encrypted);
?>
这段代码的输出是:
PHP Warning: openssl_encrypt(): IV passed is 12 bytes long which is longer than the 8 expected by selected cipher, truncating in /home/sergio/Documents/DevEnvTest/siaf/aes2hash.php on line 7
Warning: openssl_encrypt(): IV passed is 12 bytes long which is longer than the 8 expected by selected cipher, truncating in /home/sergio/Documents/DevEnvTest/siaf/aes2hash.php on line 7
gB7ahDoYZqI=
有没有办法得到和在线工具一样的字符串?
【问题讨论】:
标签: php des php-openssl