how do I initialize an encrypted variable?

150 views
Skip to first unread message

jdelabea...@gmail.com

unread,
Feb 28, 2013, 6:35:12 PM2/28/13
to sjcl-d...@googlegroups.com
Using crypto.stanford.edu/sjcl/sjcl.js, I encrypt some plain text with a password.

The encrypted data, when shown by its toString method (I suppose), is externalized as a string like

{"iv":"H6V2RJhNp0 ….. ,"ct":"MLCr2tg01DNDeEN97mEpYRg0S3X0SjH7rZ5KlUmuw1M"}

Later, I want to initialize a javascript variable with that externalized string:

var unclear = eval("({"iv":"H6V2RJhNp0 ….. ,"ct":"MLCr2tg01DNDeEN97mEpYRg0S3X0SjH7rZ5KlUmuw1M"})");

When I try to decrypt that variable (with the same password of course), I get the error

sjcl.js:40 TypeError: 'undefined' is not a function (evaluating 'a.replace(/\s/g,"")')

Any help who be appreciated.

Jim

Eamonn O'Brien-Strain

unread,
Feb 28, 2013, 7:26:04 PM2/28/13
to sjcl-d...@googlegroups.com
If you are just using the simplified API of sjcl.encrypt and sjcl.decrypt, there is no need to eval or otherwise break up the string you get from sjcl.encrypt.  You can just treat it as an opaque string, to later pass on to sjcl.decrypt

__
Eamonn


--
You received this message because you are subscribed to the Google Groups "SJCL discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sjcl-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages