I'm using localStorage in an application.
I'm using an XOR bitshift operation to mask the data before it goes into storage.
Here is the masking function:
encrypt: function (str) {
var encoded = [];
if (!App.crypto.key) {
App.crypto.init();
}
for (var i = 0, len = str.length; i < len; i++) {
var a = str.charCodeAt(i);
var b = a ^ App.crypto.key.charCodeAt(App.crypto.key % i);
encoded.push(String.fromCharCode(b));
}
return encoded.join("");
}
The value of the key I'm using in this case is "MWZ2cyt2N3JwejhxUjA2V3ptRmwxcmVvU09IbFhORHdOcDRiWGh5SGRZMFU4Ym9VY1Y1WXU5c2d6OXhBdU9wTSt1MlpqcmhXOVBRPQ0K"
When I mask "[]" in IE9 I get some weirdo characters. When I try and set that to localStorage it gives me an invalid argument error. Does anybody know what's going on?