openssl_encrypt函数有问题。
在aes-128-cbc中,为什么函数返回32字节的字符串和16字节的字符串作为输入?
样品:
$binaryK0 = openssl_encrypt(hex2bin("00000000000000000000000000000000"),"AES-128-CBC", hex2bin("00112233445566778899AABBCCDDEEFF"),OPENSSL_RAW_DATA, hex2bin("00000000000000000000000000000000"));
echo "openssl_encrypt length:".strlen($binaryK0).'<br>';
$binaryK0 = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, hex2bin("00112233445566778899AABBCCDDEEFF"), hex2bin("00000000000000000000000000000000"), MCRYPT_MODE_CBC, hex2bin("00000000000000000000000000000000"));
echo "mcrypt_encrypt length:".strlen($binaryK0).'<br>';
结果: openssl_encrypt长度:32 mcrypt_encrypt长度:16
答案 0 :(得分:0)
谢谢Topaco。
根据您的评论,我们调查了php openssl源代码。 我们找到“ OPENSSL_NO_PADDING”选项,现在可以正常使用了。
$binaryK0 = openssl_encrypt(hex2bin("00000000000000000000000000000000"),"AES-128-CBC", hex2bin("00112233445566778899AABBCCDDEEFF"),**OPENSSL_NO_PADDING**, hex2bin("00000000000000000000000000000000"));