blob: dcd64e3d7850d011c58ae5b4633da00e6c668f90 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
//License: Expat(MIT)
//Chrisoft Xiong 2017
// http://www.onicos.com/staff/iz/amuse/javascript/expert/utf.txt
function Utf8ArrayToStr(array){
var out,i,len,c;
var char2,char3;
out="";
len=array.length;
i=0;
while(i<len){
c=array[i++];
switch(c>>4)
{
case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:
// 0xxxxxxx
out+=String.fromCharCode(c);
break;
case 12:case 13:
// 110x xxxx 10xx xxxx
char2=array[i++];
out+=String.fromCharCode(((c&0x1F)<<6)|(char2&0x3F));
break;
case 14:
// 1110 xxxx 10xx xxxx 10xx xxxx
char2=array[i++];
char3=array[i++];
out+=String.fromCharCode(((c&0x0F)<<12)|
((char2&0x3F)<<6)|
((char3&0x3F)<<0));
break;
}
}
return out;
}
var decid;
function decryptui(id)
{
document.getElementById("decryptui").style.display="block";
document.getElementById("keyinp").focus();
setTimeout(function(){document.getElementById("decryptui").style.opacity="1";},20);
decid=id;
document.getElementById("keyhint").innerHTML="Hint: "+document.getElementById("encrypted"+id).getAttribute("hint");
document.getElementById("keyinp").onkeypress=function(e){if(e.keyCode==13)document.getElementById('btndecrypt').click();}
}
function hidedecryptui()
{
document.getElementById("decryptui").style.opacity="0";
setTimeout(function(){
document.getElementById("decryptui").style.display="none";
document.getElementById("keyinp").value="";
},500);
}
function decryptor(id,key)
{
var e=document.getElementById("encrypted"+id);
var cont=e.getAttribute("encont");
var bc=atob(cont);
var b=new Array(bc.length);
for(var i=0;i<bc.length;++i)b[i]=bc.charCodeAt(i);
var lkey=key.length;
var u8arr=new Uint8Array(b);
var hash=5381;
for(var i=0;i<u8arr.length;++i){u8arr[i]^=key.charCodeAt(i%lkey);hash=(hash*33)+u8arr[i];hash%=4294967296;}
if(hash!=parseInt(e.getAttribute("hash")))
{
alert("The decryption key you have entered could be wrong, please try again.");
return;
}
//e.innerHTML=new TextDecoder("utf-8").decode(u8arr);
e.innerHTML=Utf8ArrayToStr(u8arr);
footnoter();
hidedecryptui();
}
|