Created
May 24, 2012 04:06
-
-
Save julescarbon/2779360 to your computer and use it in GitHub Desktop.
leemon passphrase generator (decoded)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// beautiful.. http://www.leemon.com/crypto/MakePass.html | |
// this is the html-entity-encoded onchange event | |
// decoded with http://www.strictly-software.com/htmlencoder | |
//XOR the current time and last key pressed into the entropy pool, and hash it | |
fingerprint[0] ^= (t.z.value=='' || t.z.value==null || t.z.length==0) ? 0 : t.z.value.charCodeAt(t.z.value.length-1); | |
fingerprint[1] ^= (new Date()).getTime(); | |
fingerprint[2] ^= nBits; | |
fingerprint[3] ^= nPass; | |
//t.z.value=hexFingerprint(); | |
init(hexFingerprint()); | |
hash(); | |
nBits++; //assume 1 bit of entropy per keystroke | |
t.y.value=nBits; | |
t.f.value=nPass; | |
if (nBits==128) { | |
nw=open('empty.html','output','width=630,height=560,scrollbars=1,resizable=1,menubar=1'); | |
for (i=0;i<5;i++) //convert array fingerprint[0..4] of 32-bit words into array b[0..159] of bits | |
for (j=0;j<32;j++) | |
b[i*32+j]=(fingerprint[i] & (1<<j)) ? 1 : 0; | |
w='<html><BODY background=../links/background.jpg bgColor=#e8e8e8 link=#00c000 alink=#00c000 vlink=#004000>' | |
+'<center>' | |
+' <table border=0 cellspacing=0 cellpadding=0 bgcolor=green>' | |
+' <tr><Td width=520 align=center><font size=+2 color=lime><b>A 128-bit Passphrase Encoded 13 Different Ways</b></font></td></tr>' | |
+' </table>' | |
+'<table border=0 cellspacing=0 cellpadding=0><tr><td align=center><table border=3 bgColor=#e8e8e8><tr><td align=center>'; | |
t.z.value=''; | |
nBits=0; | |
nPass++; | |
for (i=0;i<128;i+=12) { //6-letter English words (132 bits) | |
if (i%48==0 && i>0) w+='<br>\n'; | |
for (s=0,k=0;k<12;k++) | |
s+=b[i+k]<<k; | |
w+=words6[s]+' '; | |
} | |
w+='</td>\n</tr><tr><td align=center>'; | |
for (i=0;i<128;i+=11) { //4-letter English words (128 bits) | |
if (i%44==0 && i>0) w+='<br>\n'; | |
for (s=0,k=0;k<11;k++) | |
s+=b[i+k]<<k; | |
w+=(words4[s]+' ').toLowerCase(); | |
} | |
w+='</td>\n</tr><tr><td align=center>'; | |
for (i=0,j=0;j<12;j++) //simple nonsense words (132 bits) | |
w+=c[b[i++]+(b[i++]<<1)+(b[i++]<<2)+(b[i++]<<3)]+ | |
v[b[i++]+(b[i++]<<1)+(b[i++]<<2)]+ | |
c[b[i++]+(b[i++]<<1)+(b[i++]<<2)+(b[i++]<<3)] | |
+ (((j+1)%3) ? '-' : (j==5) ? '\n<br>\n' : j<11 ? ' \t<br>\n' : ''); | |
w+='</td>\n</tr><tr><td align=center>'; | |
for (i=0,j=0;j<8;j++) { //complex nonsense words (128 bits) | |
s1=c1[b[i++]+(b[i++]<<1)+(b[i++]<<2)+(b[i++]<<3)+(b[i++]<<4)]; | |
s2= v[b[i++]+(b[i++]<<1)+(b[i++]<<2)]; | |
s3=c2[b[i++]+(b[i++]<<1)+(b[i++]<<2)+(b[i++]<<3)+(b[i++]<<4)]; | |
w+= (b[i++] ? s1 : s1.toUpperCase()) | |
+ (b[i++] ? s2 : s2.toUpperCase()) | |
+ (b[i++] ? s3 : s3.toUpperCase()) | |
+ (j==3 ? '\n<br>\n' : j==7 ? '' : (j==1||j==5) ? ' \t<br>\n' : '-'); | |
} | |
w+='</td>\n</tr><tr><td align=center>'; | |
for (i=0;i<128;) { //base 64 (132 bits) | |
w+=b64[(b[i++]<<5)+(b[i++]<<4)+(b[i++]<<3)+(b[i++]<<2)+(b[i++]<<1)+b[i++]]; | |
if (i==66) w+='<br>\n'; | |
} | |
w+='</td>\n</tr><tr><td align=center>'; | |
for (i=0;i<128;) { //hexadecimal (128 bits) | |
w+=hex[(b[i++]<<3)+(b[i++]<<2)+(b[i++]<<1)+b[i++]]; | |
if (i==128) break; | |
if (i%64==0) w+='\n<br>\n'; | |
else if (i%32==0) w+=' \t<br>\n'; | |
else if (i%16==0) w+=' '; | |
} | |
w+='</td>\n</tr><tr><td>\n'; | |
for (i=0,j=0;i<4;i++) { //phone numbers (130 bits) | |
w+='(' | |
+digit8(j=j+3) | |
+b[j++] | |
+digit8(j=j+3) | |
+') ' | |
+digit8(j=j+3) | |
+digit8(j=j+3) | |
+digit8(j=j+3) | |
+'-' | |
+digit8(j=j+3) | |
+digit8(j=j+3) | |
+digit8(j=j+3) | |
+digit8(j=j+3); | |
if (i>1) | |
w+=' x' | |
+digit8(j=j+3) | |
+digit8(j=j+3) | |
+digit8(j=j+3); | |
if (i<3) | |
w+='<br>\n'; | |
} | |
w+='\n</td>\n</tr></table></td>'; | |
w+='<td><table border=3 bgColor=#e8e8e8><tr><td align=center>'; | |
s=new Date(); //dates (129 bits) | |
for (i=0;i<128;i+=32) { | |
for (num=0,j=0;j<32;j++) | |
num=num*2+b[i+j] | |
s.setYear(1863);s.setMonth(0);s.setDate(1);s.setHours(0);s.setMinutes(0);s.setSeconds(0); | |
s.setTime(s.getTime()+1000*num); | |
w+=month[s.getMonth()]+' '+s.getDate()+', ' | |
+(s.getYear()<100 ? s.getYear()+1900 : s.getYear()) | |
+' '+s.getHours()+':'+s.getMinutes()+':'+s.getSeconds()+(i<128-32 ? '<br>\n' : ''); | |
} | |
w+='</td>\n</tr><tr><td align=center>'; | |
decimalDigits=''; | |
for (i=0;i<128;) { //decimal (128 bits) | |
for (s=0,k=0;k<16;k++) | |
s=2*s+b[i++]; | |
if (s< 10) {w+='0';decimalDigits+='0';} | |
if (s< 100) {w+='0';decimalDigits+='0';} | |
if (s< 1000) {w+='0';decimalDigits+='0';} | |
if (s<10000) {w+='0';decimalDigits+='0';} | |
w+=s; | |
decimalDigits+=s; | |
if (i<127) | |
w+=' '; | |
if (i==64) | |
w+='<br>\n'; | |
} | |
w+='</td>\n</tr><tr><td align=center>'; | |
for (i=j=0;i<decimalDigits.length;) { //phonetic digit words | |
if (i+2>decimalDigits.length) {w+=numWords1[1*decimalDigits.substring(i,i+1)];i+=1;} | |
else if (i+3>decimalDigits.length) {w+=numWords2[1*decimalDigits.substring(i,i+2)];i+=2;} | |
else if (numWords3[1*decimalDigits.substring(i,i+3)].charAt(0)=='.') | |
{w+=numWords2[1*decimalDigits.substring(i,i+2)];i+=2;} | |
else {w+=numWords3[1*decimalDigits.substring(i,i+3)];i+=3;}; | |
if (i<decimalDigits.length) | |
w += (((++j)%4) ? ' ' : '<br>'); | |
} | |
w+='<br>\n</td>\n</tr><tr><td align=center><table border=0 cellspacing=0 cellpadding=0>'; | |
for (k=0,i=0;i<9;i++) { //black and white picture (128 bits) | |
w+='<tr>'; | |
for (j=0;j<17;j++) { | |
col=(j==8 || i==4) ? '#e8e8e8' : b[k++] ? 'black' : 'white'; | |
pix=col=='black' ? '###' : '---'; | |
w+='<td bgColor='+col+'><font color='+col+' size=1>'+pix+'</font></td>\n'; | |
} | |
w+='</tr>\n'; | |
} | |
w+='</table>\n</td>\n</tr><tr><td align=center><table border=0 cellspacing=0 cellpadding=0 cellspacing=0 cellpadding=0>'; | |
for (k=0,i=0;i<4/*2*/;i++) { //color picture (128 bits) | |
w+='<tr>'; | |
for (j=0;j<9/*17*/;j++) { | |
if (j==4/*8*/) | |
col='#e8e8e8'; | |
else | |
col=colors[8*b[k++] + 4*b[k++] + 2*b[k++] + b[k++]]; | |
w+='<td bgColor='+col+'><font color='+col+' size=1>###</font></td>\n'; | |
} | |
w+='</tr>\n'; | |
} | |
w+='</table></td>\n</tr><tr><td align=center>'; | |
for (i=0;i<128;i++) | |
w+=b[i]+(((i+1)%32 || i==127) ? '' : '<br>'); | |
w+='</td></tr></table></td></tr></table></body></html>'; | |
nw.document.write(w); | |
nw.document.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment