在 PHP 中取消加密/重新加密 ColdFusion 加密字符串
我的处境并不令人羡慕,我必须维护现有 ColdFusion 应用程序的功能。作为登录过程的一部分,Coldfusion 应用程序存储带有加密字符串的 cookie。
encrypt(strToEncrypt, theKey, "AES", "Base64")
我可以使用 MCrypt 和以下代码在 PHP 中成功解密该字符串,
mcrypt_decrypt(
MCRYPT_RIJNDAEL_128,
base64_decode($theKey),
base64_decode($encrypted_string),
MCRYPT_MODE_ECB, "0000000000000000")
现在我需要在 PHP 中执行相同的加密,以便 ColdFusion 应用程序可以访问 cookie 中的数据。
然而,目前我所拥有的是
mcrypt_encrypt( MCRYPT_RIJNDAEL_128, base64_decode($theKey), $strToEncrypt, MCRYPT_MODE_ECB, "0000000000000000");
,这与等效的 ColdFusion 加密算法不兼容,
decrypt(strToDecrypt, theKey, "AES", "Base64")
抛出 Given Final block notproperly padded
错误。
非常感谢任何帮助。
詹姆斯
I'm in the unenviable position where I have to maintain functionality with an existing ColdFusion application. As part of it's login process the Coldfusion app stores a cookie with an encrypted string.
encrypt(strToEncrypt, theKey, "AES", "Base64")
I can successfully decrypt this string in PHP using MCrypt and the following code
mcrypt_decrypt(
MCRYPT_RIJNDAEL_128,
base64_decode($theKey),
base64_decode($encrypted_string),
MCRYPT_MODE_ECB, "0000000000000000")
I now have the need to perform the same encryption within PHP so that the ColdFusion app can access the data in the cookie.
At the moment what I have is
mcrypt_encrypt( MCRYPT_RIJNDAEL_128, base64_decode($theKey), $strToEncrypt, MCRYPT_MODE_ECB, "0000000000000000");
This, however, is incompatible with the equivalent ColdFusion encryption algorithm
decrypt(strToDecrypt, theKey, "AES", "Base64")
Throwing a Given final block not properly padded
error.
Any help much appreciated.
James
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不知道这会有多大帮助,但我已经进行了以下工作。我认为要让 CF 满意,您必须将加密填充到一定长度
在 CF 中
加密 在 PHP 中
解密 在 PHP 中
加密 在 CF 中解密
由于某种我不记得的原因,我更喜欢使用“uu”进行编码。
Don't know how much help this will be but I have had the following working. I think to make CF happy you have to pad your encryption to a certain length
Encrypt in CF
Decrypt in PHP
Encrypt in PHP
Decrypt in CF
For some reason that I can't remember, I favoured 'uu' for the encoding.