0

我有一个字符串让我们说选择 =“要加密和解密的文本” 我正在使用我用另一个程序生成的公钥进行加密,它工作正常。我得到密文并尝试对其进行解密,但出现以下错误。

script.js:282 the pub key is : 021e645806ee84055b51------675e75f93d41c407b7826cf1e76c10aaa05dfc8e
script.js:291 the cipher text is: gkEJlPREx/EVPUue3vWlDWImilRrnyUmeNpkvSbY1vVLqf6IYoBqk9H/PBwXXck++Q==?T+kht1n981qDPmJc7H3DrFxqRi2oe6OFu60ASI389Rg=
script.js:303 the priv key is : 2293f6d33--------f37cc02674edec14eae9586c4fab5bd2a89631f10237b13
cryptico.js:3499 Uncaught TypeError: ciphertext.split is not a function
    at Object.my.decrypt (cryptico.js:3499)
    at Object.success (script.js:306)
    at u (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at k (jquery.min.js:2)
    at XMLHttpRequest.<anonymous> (jquery.min.js:2)

当我查找错误时,它停在解密函数的第二行

my.decrypt = function(ciphertext, key)
    {
        var cipherblock = ciphertext.split("?");
        var aeskey = key.decrypt(my.b64to16(cipherblock[0]));}

我知道密码在“?”上分裂。但我可以看到我的密码中有它。有什么问题?ps 我将破折号添加到替换原始值的键中

@更新

我使用了此页面https://github.com/wwwtyro/cryptico中的示例,但遇到了同样的错误。所以我将代码更改如下

let EncryptionResult = cryptico.encrypt(choice, pub_key);
let DecryptionResult = cryptico.decrypt(EncryptionResult.cipher, priv_key);

现在它通过了原始错误,但我收到了第二个错误

cryptico.js:3500 Uncaught TypeError: key.decrypt is not a function
    at Object.my.decrypt (cryptico.js:3500)
    at Object.success (script.js:303)
    at u (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at k (jquery.min.js:2)
    at XMLHttpRequest.<anonymous> (jquery.min.js:2)
    enter code here

它停在第二行var aeskey = key.decrypt(my.b64to16(cipherblock[0])); . 这与base64有什么关系吗?我的密钥是十六进制编码的,我不知道这是否有帮助。

4

0 回答 0