Javascript Error using cryptico library for decryption



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















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.










share|improve this question



















  • 1





    your error suggests that your ciphertext variable is not a string, what does show console.log(typeof ciphertext);?

    – Kaddath
    Nov 15 '18 at 13:50











  • It shows string. But you where right, I was using the variable without the ".cipher" extension. This passed the original problem but no I am getting Uncaught TypeError: key.decrypt is not a function

    – Cheetara
    Nov 15 '18 at 14:03












  • The new error suggests that your second parameter given to cryptico.decrypt, priv_key shouldn't be a string but an object that should have a decrypt function. Don't have time to check the examples, but i guess this parameter should be constructed with the library?

    – Kaddath
    Nov 15 '18 at 16:11






  • 1





    There's a very strong chance that it doesn't support a key from another library, as it directly runs functions on it without testing their existence. But it's quite normal if the library expects an object instead of something simple like a string (and usual in cryptography). You can try to build a cryptico key object from your existing key object properties if you are forced to use another lib for the keys. If you run into troubles, that's probably subject for a new question with a more precise title instead of editing this one.. (you can still link the new question here for me if the case)

    – Kaddath
    Nov 16 '18 at 9:24






  • 1





    Very helpful information and answers :-) I consider the question as completely answered! You saved my day.

    – Cheetara
    Nov 16 '18 at 11:03


















0















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.










share|improve this question



















  • 1





    your error suggests that your ciphertext variable is not a string, what does show console.log(typeof ciphertext);?

    – Kaddath
    Nov 15 '18 at 13:50











  • It shows string. But you where right, I was using the variable without the ".cipher" extension. This passed the original problem but no I am getting Uncaught TypeError: key.decrypt is not a function

    – Cheetara
    Nov 15 '18 at 14:03












  • The new error suggests that your second parameter given to cryptico.decrypt, priv_key shouldn't be a string but an object that should have a decrypt function. Don't have time to check the examples, but i guess this parameter should be constructed with the library?

    – Kaddath
    Nov 15 '18 at 16:11






  • 1





    There's a very strong chance that it doesn't support a key from another library, as it directly runs functions on it without testing their existence. But it's quite normal if the library expects an object instead of something simple like a string (and usual in cryptography). You can try to build a cryptico key object from your existing key object properties if you are forced to use another lib for the keys. If you run into troubles, that's probably subject for a new question with a more precise title instead of editing this one.. (you can still link the new question here for me if the case)

    – Kaddath
    Nov 16 '18 at 9:24






  • 1





    Very helpful information and answers :-) I consider the question as completely answered! You saved my day.

    – Cheetara
    Nov 16 '18 at 11:03














0












0








0








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.










share|improve this question
















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.







javascript encryption rsa cryptico






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 14:12







Cheetara

















asked Nov 15 '18 at 13:47









CheetaraCheetara

338




338







  • 1





    your error suggests that your ciphertext variable is not a string, what does show console.log(typeof ciphertext);?

    – Kaddath
    Nov 15 '18 at 13:50











  • It shows string. But you where right, I was using the variable without the ".cipher" extension. This passed the original problem but no I am getting Uncaught TypeError: key.decrypt is not a function

    – Cheetara
    Nov 15 '18 at 14:03












  • The new error suggests that your second parameter given to cryptico.decrypt, priv_key shouldn't be a string but an object that should have a decrypt function. Don't have time to check the examples, but i guess this parameter should be constructed with the library?

    – Kaddath
    Nov 15 '18 at 16:11






  • 1





    There's a very strong chance that it doesn't support a key from another library, as it directly runs functions on it without testing their existence. But it's quite normal if the library expects an object instead of something simple like a string (and usual in cryptography). You can try to build a cryptico key object from your existing key object properties if you are forced to use another lib for the keys. If you run into troubles, that's probably subject for a new question with a more precise title instead of editing this one.. (you can still link the new question here for me if the case)

    – Kaddath
    Nov 16 '18 at 9:24






  • 1





    Very helpful information and answers :-) I consider the question as completely answered! You saved my day.

    – Cheetara
    Nov 16 '18 at 11:03













  • 1





    your error suggests that your ciphertext variable is not a string, what does show console.log(typeof ciphertext);?

    – Kaddath
    Nov 15 '18 at 13:50











  • It shows string. But you where right, I was using the variable without the ".cipher" extension. This passed the original problem but no I am getting Uncaught TypeError: key.decrypt is not a function

    – Cheetara
    Nov 15 '18 at 14:03












  • The new error suggests that your second parameter given to cryptico.decrypt, priv_key shouldn't be a string but an object that should have a decrypt function. Don't have time to check the examples, but i guess this parameter should be constructed with the library?

    – Kaddath
    Nov 15 '18 at 16:11






  • 1





    There's a very strong chance that it doesn't support a key from another library, as it directly runs functions on it without testing their existence. But it's quite normal if the library expects an object instead of something simple like a string (and usual in cryptography). You can try to build a cryptico key object from your existing key object properties if you are forced to use another lib for the keys. If you run into troubles, that's probably subject for a new question with a more precise title instead of editing this one.. (you can still link the new question here for me if the case)

    – Kaddath
    Nov 16 '18 at 9:24






  • 1





    Very helpful information and answers :-) I consider the question as completely answered! You saved my day.

    – Cheetara
    Nov 16 '18 at 11:03








1




1





your error suggests that your ciphertext variable is not a string, what does show console.log(typeof ciphertext);?

– Kaddath
Nov 15 '18 at 13:50





your error suggests that your ciphertext variable is not a string, what does show console.log(typeof ciphertext);?

– Kaddath
Nov 15 '18 at 13:50













It shows string. But you where right, I was using the variable without the ".cipher" extension. This passed the original problem but no I am getting Uncaught TypeError: key.decrypt is not a function

– Cheetara
Nov 15 '18 at 14:03






It shows string. But you where right, I was using the variable without the ".cipher" extension. This passed the original problem but no I am getting Uncaught TypeError: key.decrypt is not a function

– Cheetara
Nov 15 '18 at 14:03














The new error suggests that your second parameter given to cryptico.decrypt, priv_key shouldn't be a string but an object that should have a decrypt function. Don't have time to check the examples, but i guess this parameter should be constructed with the library?

– Kaddath
Nov 15 '18 at 16:11





The new error suggests that your second parameter given to cryptico.decrypt, priv_key shouldn't be a string but an object that should have a decrypt function. Don't have time to check the examples, but i guess this parameter should be constructed with the library?

– Kaddath
Nov 15 '18 at 16:11




1




1





There's a very strong chance that it doesn't support a key from another library, as it directly runs functions on it without testing their existence. But it's quite normal if the library expects an object instead of something simple like a string (and usual in cryptography). You can try to build a cryptico key object from your existing key object properties if you are forced to use another lib for the keys. If you run into troubles, that's probably subject for a new question with a more precise title instead of editing this one.. (you can still link the new question here for me if the case)

– Kaddath
Nov 16 '18 at 9:24





There's a very strong chance that it doesn't support a key from another library, as it directly runs functions on it without testing their existence. But it's quite normal if the library expects an object instead of something simple like a string (and usual in cryptography). You can try to build a cryptico key object from your existing key object properties if you are forced to use another lib for the keys. If you run into troubles, that's probably subject for a new question with a more precise title instead of editing this one.. (you can still link the new question here for me if the case)

– Kaddath
Nov 16 '18 at 9:24




1




1





Very helpful information and answers :-) I consider the question as completely answered! You saved my day.

– Cheetara
Nov 16 '18 at 11:03






Very helpful information and answers :-) I consider the question as completely answered! You saved my day.

– Cheetara
Nov 16 '18 at 11:03













0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53320891%2fjavascript-error-using-cryptico-library-for-decryption%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53320891%2fjavascript-error-using-cryptico-library-for-decryption%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

Syphilis

Darth Vader #20