wok-6.x view zerobin/stuff/zerobin.u @ rev 12953
zerobin: append '=' to forced key
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu May 31 13:45:40 2012 +0200 (2012-05-31) |
parents | 1edf8ba1ba4e |
children | a6697022a666 |
line source
1 --- lib/zerobin.js
2 +++ lib/zerobin.js
3 @@ -180,7 +180,12 @@
4 {
5 if ($('textarea#message').val().length==0) return; // Do not send if no data.
6 showStatus('Sending paste...',spin=true);
7 - var randomkey = sjcl.codec.base64.fromBits(sjcl.random.randomWords(8,0),0);
8 + var randomkey = (window.location.hash.length > 2) ?
9 + // force key
10 + window.location.hash.substring(1) :
11 + // Generate a random 256 bits key, encoded in base64:
12 + sjcl.codec.base64.fromBits(sjcl.random.randomWords(8,0),0);
13 + if (randomkey.charAt(randomkey.length-1)!=='=') randomkey+='='; // Add trailing = if missing.
14 var cipherdata = zeroCipher(randomkey,$('textarea#message').val());
15 var data_to_send = { data:cipherdata,
16 expire:$('select#pasteExpiration').val(),