【发布时间】:2020-05-02 08:49:50
【问题描述】:
我正在尝试生成用于解码已使用 ColdFusion 加密的密码的密钥。当我在binaryDecode(string, "hex") 中传递参数时,我得到了不同的结果。如何将其翻译成 JavaScript?
在 ColdFusion 中:
binaryDecode("CA993CED42F374C9291FC2484495CD9334E8C822", "hex")
output is: -54-10360-1966-13116-554131-627268-107-51-10952-24-5634 (binary)
after that the output will be looped and store in array variable
then binaryEncode(javaCast("byte[]", arrayVariable), "Base64")
the result is generatedKey
in Node js:
i didnt get the same output after the binaryDecode
43413939334345443432463337344339323931464332343834343935434439333334453843383232
I tried using `buffer.from()` but it just split to `43 41 39` etc.
我尝试了很多东西,但我无法得到 -54-10360-1966-13116-554131-627268-107-51-10952-24-5634 的结果
【问题讨论】:
-
您确定您查看的是正确的 ColdFusion 代码吗?您说您正在尝试“解码”密码,但
binaryDecode()函数不用于加密。它用于将字符串数据转换回二进制数据。 -
是的 binaryDecode 的返回将用作解码加密的密钥,但我只是意识到 CA993CED42F374C9291FC2484495CD9334E8C822 需要转换为十六进制字节,然后我需要 BASE64 编码,我注意到来自cryptii.com/pipes/base64-to-hex ,我只是不明白 binaryDecode 做了什么
标签: javascript node.js coldfusion