minor typo fix in sha1.js; passy-tiny.html added
This commit is contained in:
1 parent
152c466056
commit
04d4ec7e0c
2 files changed
+68
-1
No files matched your search
@@ -0,0 +1,67 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
|
||||
<script type='text/javascript'>
|
||||
var u=function(){function t(a){var d=[];do{d.unshift(a&255);a>>=8}while(a);return d}function s(a){var d=[],b,c=a.length;for(b=0;b<c;b++)d=d.concat(t(a.charCodeAt(b)));return d}function o(a){a=a.slice();var d=a.length*8,b=1732584193,c=4023233417,j=2562383102,g=271733878,h=3285377520,e,i,f,k,q,m,r,n,p;for(a.push(128);(a.length+8)%64;)a.push(0);a=a.concat([(d&1.8374686479671624E19)>>>56,(d&71776119061217280)>>>48,(d&280375465082880)>>>40,(d&1095216660480)>>>32,(d&4278190080)>>>24,(d&16711680)>>>16,(d& 65280)>>>8,d&255]);for(d=0;d<a.length/64;d++){e=a.slice(d*64,d*64+64);i=[];f=void 0;k=e.length;for(f=0;f<k;f+=4)i.push(e[f]<<24|e[f+1]<<16|e[f+2]<<8|e[f+3]);n=i;e=b;i=c;f=j;k=g;q=h;for(p=0;p<80;p++){m=p&15;if(p>=16){r=n[m+13&15]^n[m+8&15]^n[m+2&15]^n[m];n[m]=r<<1|r>>>31}r=p<20?(e<<5|e>>>27)+(k^i&(f^k))+q+1518500249+n[m]&4294967295:p<40?(e<<5|e>>>27)+(i^f^k)+q+1859775393+n[m]&4294967295:p<60?(e<<5|e>>>27)+(i&f|i&k|f&k)+q+2400959708+n[m]&4294967295:(e<<5|e>>>27)+(i^f^k)+q+3395469782+n[m]&4294967295; q=k;k=f;f=i<<30|i>>>2;i=e;e=r}b=b+e&4294967295;c=c+i&4294967295;j=j+f&4294967295;g=g+k&4294967295;h=h+q&4294967295}return[b>>>24&255,b>>>16&255,b>>>8&255,b&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,j>>>24&255,j>>>16&255,j>>>8&255,j&255,g>>>24&255,g>>>16&255,g>>>8&255,g&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255]}var l=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return{a:function(a,d){var b=s(a),c=s(d),j=Array(64),g=Array(64),h;if(b.length>64)b=o(b);for(;b.length<64;)b.push(0); for(h=0;h<64;h++){j[h]=92^b[h];g[h]=54^b[h]}b=o(j.concat(o(g.concat(c))));c="";j=b.length;for(g=0;g<j;g++)c+=l[b[g]>>>4]+l[b[g]&15];return c}}}(); window.passy=function(t,s){function o(a){var d={"1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")"},b=true,c;for(c=0;c<a.length;++c)if(/[0-9]/.test(a[c])){if(b)a=a.slice(0,c)+d[a[c]]+a.slice(c+1,a.length);b=!b}b=true;for(c=0;c<a.length;++c)if(/[a-f]/i.test(a[c])){a=a.slice(0,c)+(b?a[c].toUpperCase():a[c].toLowerCase())+a.slice(c+1,a.length);b=!b}return a}var l=u.a(s,t);return[o(l.slice(0,10)),o(l.slice(10,20)),o(l.slice(20,30)),o(l.slice(30,40)),l.slice(0,10),l.slice(10, 20),l.slice(20,30),l.slice(30,40)]};
|
||||
</script>
|
||||
|
||||
<script type='text/javascript'>
|
||||
var password_timer=0;
|
||||
function delayed_select(target)
|
||||
{
|
||||
// hack to wait for onmouseup event to pass
|
||||
setTimeout(function(){target.select()},5); // 5ms
|
||||
}
|
||||
function clear_password()
|
||||
{
|
||||
// clear password field and set focus so we're ready to receive password again
|
||||
document.getElementById('password').value = "";
|
||||
document.getElementById('password').focus();
|
||||
|
||||
// force an update to clear the generated password (result) field as well
|
||||
update_passy();
|
||||
}
|
||||
function update_passy()
|
||||
{
|
||||
// do password update
|
||||
var site = document.getElementById('site').value;
|
||||
var password = document.getElementById('password').value;
|
||||
if ( site == "" || password == "" )
|
||||
{
|
||||
document.getElementById('result').value = "";
|
||||
document.getElementById('result_old').value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById('result').value = passy(site,password)[0];
|
||||
document.getElementById('result_old').value = passy(site,password)[4];
|
||||
}
|
||||
|
||||
// set timer to clear password field after a minute
|
||||
if ( password_timer != 0 )
|
||||
{
|
||||
clearTimeout(password_timer);
|
||||
}
|
||||
password_timer = setTimeout('clear_password()',60000);
|
||||
}
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form>
|
||||
Site Name:<br/>
|
||||
<input type='text' id='site' onkeyup='update_passy()'><br/>
|
||||
Secret Passphrase:<br/>
|
||||
<input type='password' id='password' onkeyup='update_passy()'><br/>
|
||||
<hr/>
|
||||
Site Password:<br/>
|
||||
<input type='text' id='result' readonly onfocus='delayed_select(this)'>
|
||||
<br/>
|
||||
Site Password (old version):<br/>
|
||||
<input type='text' id='result_old' readonly onfocus='delayed_select(this)'>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -276,7 +276,7 @@ var SHA1 = (function() // SHA1 "namespace"
|
||||
[ byte_string(0xaa,20),byte_string(0xdd,50), '125d7342b9ac11cd91a39af48aa17b4f63f175d3' ],
|
||||
[ byte_string(0xc,20),'Test With Truncation','4c1a03424b55e07fe7f27be1d58bb9324a9a5a04' ],
|
||||
[ byte_string(0xaa,80),'Test Using Larger Than Block-Size Key - Hash Key First','aa4ae5e15272d00e95705637ce8a3b55ed402112' ],
|
||||
[ byte_string(0xaa,80),'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data','e8e99d0f45237d786d6bbaa7965c7808bbff1a91' ],
|
||||
[ byte_string(0xaa,80),'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data','e8e99d0f45237d786d6bbaa7965c7808bbff1a91' ]
|
||||
];
|
||||
|
||||
for (var i = 0; i < tests.length; i++) {
|
||||
|
||||
Reference in new issue
Block a user