I have a string let's say choice="text to encrypt and decrypt" I am using a public key I produced with another program to encrypt and it works fine. I get the cipher text and try to decrypt it, but I am getting the following error.
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)
and when I look for the error it stops at the second line of the decrypt function
my.decrypt = function(ciphertext, key)
{
var cipherblock = ciphertext.split("?");
var aeskey = key.decrypt(my.b64to16(cipherblock[0]));}
I understand that the cipher code splits on the "?" but I can see that I have it in my cipher code. What can be wrong? p.s. I added the dashes to the keys replacing the original values
@UPDATE
I used the example from this page https://github.com/wwwtyro/cryptico and I was getting the same error. So I changed the code as follows
let EncryptionResult = cryptico.encrypt(choice, pub_key);
let DecryptionResult = cryptico.decrypt(EncryptionResult.cipher, priv_key);
Now it passes the original error but I am getting a second error
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
and it stops at the second line var aeskey = key.decrypt(my.b64to16(cipherblock[0])); . Does this have to do anything with base64?? My keys are hex encoded, I don't know if this helps.