Php openssl\u加密最后的字节是错误的

Php openssl\u加密最后的字节是错误的,php,encryption,Php,Encryption,我在使用openssl\u encrypt时遇到问题。最后8个字节似乎是错误的。当我将加密字符串与在线工具()的字符串进行比较时,除了最后8个字节外,它们完全相同。对于AES,最后16个字节将不同 有人能解释一下区别吗?任何帮助都将受到欢迎 PHP代码: $method = 'DES-CBC'; $cipherKey = 'CsflsUHV'; $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($method)); $iv =

我在使用
openssl\u encrypt
时遇到问题。最后8个字节似乎是错误的。当我将加密字符串与在线工具()的字符串进行比较时,除了最后8个字节外,它们完全相同。对于AES,最后16个字节将不同

有人能解释一下区别吗?任何帮助都将受到欢迎

PHP代码:

$method = 'DES-CBC';
$cipherKey = 'CsflsUHV';
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($method));
$iv = $iv ^ $iv; // this will ensure an IV composed of zeroes only
$plainText = 'This is my plain text to encrypt.';
echo implode(' ', str_split(bin2hex(openssl_encrypt($plainText, $method, $cipherKey, OPENSSL_RAW_DATA, $iv)), 2));
结果(顶部是PHP,底部是des.online domain tools.com):

注意:我知道DES已经过时,IV不应该是零,但这是一个简单的例子,可以了解出了什么问题


谢谢你的帮助。

这就是问题所在。为什么您需要像某些在线工具一样工作的代码?请确保您的工作和在线工具使用相同的填充,将填充设置为PKCS5或自己执行。您会注意到您的在线工具会很高兴地从PHP代码中解密数据。好的,这确实是填充,谢谢大家。@ArtjomB。因为这个在线工具提供的输出与我正在使用的实际系统相同。
9f 47 5d 8b 7d c3 4b 55 96 b9 27 86 c2 e8 d1 fc 68 7d 6e 83 49 fa 3b af 04 73 da e8 c8 3c a4 bc 3a 94 c8 c3 ab e6 36 22

9f 47 5d 8b 7d c3 4b 55 96 b9 27 86 c2 e8 d1 fc 68 7d 6e 83 49 fa 3b af 04 73 da e8 c8 3c a4 bc e6 6d 49 c9 3d 44 ca e7