Generate shorter 48-bit keys in the interface js

This commit is contained in:
Mike Kazantsev 2013-04-30 01:05:19 +06:00 committed by fraggod@sacrilege
parent 6675209e31
commit d82669e8ee
1 changed files with 8 additions and 5 deletions

View File

@ -152,10 +152,13 @@
}, 250); /* End of "decrypt" */
},
/** Create a random base64 string long enought to be suitable as
an encryption key */
makeKey: function () {
return sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0);
/** Create a random base64-like string long enought to be suitable as
an encryption key */
makeKey: function (entropy) {
entropy = Math.ceil(entropy / 6) * 6; /* non-6-multiple produces same-length base64 */
var key = sjcl.bitArray.clamp(
sjcl.random.randomWords(Math.ceil(entropy / 32), 0), entropy );
return sjcl.codec.base64.fromBits(key, 0).replace(/\=+$/, '').replace(/\//, '-');
},
getFormatedDate: function (date) {
@ -511,7 +514,7 @@
try {
var expiration = $('#expiration').val();
var key = zerobin.makeKey();
var key = zerobin.makeKey(48);
zerobin.encrypt(key, paste,