Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 1445 characters in body
Source Link
sunetos
  • 3.5k
  • 1
  • 25
  • 14

I believe I came across one by Paul Johnston at http://pajhome.org.uk/crypt/md5/contrib/sha1_stream.js . It is listed on the page http://pajhome.org.uk/crypt/md5/scripts.html . I have not tested it myself, but I have used his non-streamable version that he modified for it.

UPDATE: Here is some example code (I verified it against a separate SHA1 known to be correct). Make sure you include the original sha1.js (found at http://pajhome.org.uk/crypt/md5/sha1.js) before the streamable sha1_stream.js.

<script src="sha1.js" type="text/javascript" charset="utf-8"></script> <script src="sha1_stream.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript" charset="utf-8"> var input = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'; var blocksize = 512; var h = naked_sha1_head(); for (var i = 0; i < input.length; i += blocksize) { var len = Math.min(blocksize, input.length - i); var block = input.substr(i, len); naked_sha1(str2binb(block), len*chrsz, h); } var result = binb2hex(naked_sha1_tail(h)); </script> 

I believe I came across one by Paul Johnston at http://pajhome.org.uk/crypt/md5/contrib/sha1_stream.js . It is listed on the page http://pajhome.org.uk/crypt/md5/scripts.html . I have not tested it myself, but I have used his non-streamable version that he modified for it.

I believe I came across one by Paul Johnston at http://pajhome.org.uk/crypt/md5/contrib/sha1_stream.js . It is listed on the page http://pajhome.org.uk/crypt/md5/scripts.html . I have not tested it myself, but I have used his non-streamable version that he modified for it.

UPDATE: Here is some example code (I verified it against a separate SHA1 known to be correct). Make sure you include the original sha1.js (found at http://pajhome.org.uk/crypt/md5/sha1.js) before the streamable sha1_stream.js.

<script src="sha1.js" type="text/javascript" charset="utf-8"></script> <script src="sha1_stream.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript" charset="utf-8"> var input = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'; var blocksize = 512; var h = naked_sha1_head(); for (var i = 0; i < input.length; i += blocksize) { var len = Math.min(blocksize, input.length - i); var block = input.substr(i, len); naked_sha1(str2binb(block), len*chrsz, h); } var result = binb2hex(naked_sha1_tail(h)); </script> 
Source Link
sunetos
  • 3.5k
  • 1
  • 25
  • 14

I believe I came across one by Paul Johnston at http://pajhome.org.uk/crypt/md5/contrib/sha1_stream.js . It is listed on the page http://pajhome.org.uk/crypt/md5/scripts.html . I have not tested it myself, but I have used his non-streamable version that he modified for it.