Commit bd2492e6 authored by JC Brand's avatar JC Brand

Encrypt messages stored in localstorage.

parent e235fa44
...@@ -109,13 +109,18 @@ ...@@ -109,13 +109,18 @@
if (msgs.length >= 30) { if (msgs.length >= 30) {
msgs.shift(); msgs.shift();
} }
msgs.push(now+' '+direction+' '+msg); msgs.push(sjcl.encrypt(hex_sha1(this.get('own_jid')), now+' '+direction+' '+msg));
store.set(hex_sha1(this.get('own_jid')+bare_jid), msgs); store.set(hex_sha1(this.get('own_jid')+bare_jid), msgs);
}, },
getMessages: function (jid) { getMessages: function (jid) {
var bare_jid = Strophe.getBareJidFromJid(jid); var bare_jid = Strophe.getBareJidFromJid(jid),
return store.get(hex_sha1(this.get('own_jid')+bare_jid)) || []; decrypted_msgs = [];
var msgs =store.get(hex_sha1(this.get('own_jid')+bare_jid)) || [];
for (var i=0; i<msgs.length; i++) {
decrypted_msgs.push(sjcl.decrypt(hex_sha1(this.get('own_jid')), msgs[i]));
}
return decrypted_msgs
} }
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment