Created
January 25, 2024 04:54
-
-
Save rndme/1983f3e073953a884ef526eedd1350f5 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined | |
* in FIPS 180-1 | |
* Version 2.2 Copyright Paul Johnston 2000 - 2009. | |
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet | |
* Distributed under the BSD License | |
* See http://pajhome.org.uk/crypt/md5 for details. | |
*/ | |
// smooooshed by dandavis 2024. tested in jscript5.5 | |
var sha1=function(v){function h(d,c){var a=(d&65535)+(c&65535);return(d>>16)+(c>>16)+(a>>16)<<16|a&65535}var m=0;return function(d){var c="";for(var a=-1,b,e;++a<d.length;)b=d.charCodeAt(a),e=a+1<d.length?d.charCodeAt(a+1):0,55296<=b&&56319>=b&&56320<=e&&57343>=e&&(b=65536+((b&1023)<<10)+(e&1023),a++),127>=b?c+=String.fromCharCode(b):2047>=b?c+=String.fromCharCode(192|b>>>6&31,128|b&63):65535>=b?c+=String.fromCharCode(224|b>>>12&15,128|b>>>6&63,128|b&63):2097151>=b&&(c+=String.fromCharCode(240|b>>> | |
18&7,128|b>>>12&63,128|b>>>6&63,128|b&63));d=Array(c.length>>2);for(a=0;a<d.length;a++)d[a]=0;for(a=0;a<8*c.length;a+=8)d[a>>5]|=(c.charCodeAt(a/8)&255)<<24-a%32;c=8*c.length;d[c>>5]|=128<<24-c%32;d[(c+64>>9<<4)+15]=c;c=Array(80);a=1732584193;b=-271733879;e=-1732584194;for(var g=271733878,k=-1009589776,n=0;n<d.length;n+=16){for(var p=a,q=b,r=e,t=g,u=k,f=0;80>f;f++){if(16>f)c[f]=d[n+f];else{var l=c[f-3]^c[f-8]^c[f-14]^c[f-16];c[f]=l<<1|l>>>31}l=h(h(a<<5|a>>>27,20>f?b&e|~b&g:40>f?b^e^g:60>f?b&e|b&g| | |
e&g:b^e^g),h(h(k,c[f]),20>f?1518500249:40>f?1859775393:60>f?-1894007588:-899497514));k=g;g=e;e=b<<30|b>>>2;b=a;a=l}a=h(a,p);b=h(b,q);e=h(e,r);g=h(g,t);k=h(k,u)}d=[a,b,e,g,k];c="";for(a=0;a<32*d.length;a+=8)c+=String.fromCharCode(d[a>>5]>>>24-a%32&255);d=c;try{m}catch(w){m=0}c=m?"0123456789ABCDEF":"0123456789abcdef";a="";for(e=0;e<d.length;e++)b=d.charCodeAt(e),a+=c.charAt(b>>>4&15)+c.charAt(b&15);return a}}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment