javascript - How to find a SHA1 encrypted string from the 5-word encrypted hash in Ruby? -
say you're encrypting string "alextoul" cryptojs.sha1.
as explained in source below object looks that:
cryptojs.sha1("alextoul") = {words: { 0: 1025575641 1: -2026381578 2: 1077518901 3: 1028391820 4: 1049226021 }}
turns out if convert string get:
cryptojs.sha1("alextoul").tostring() = "3d210ad98737def64039a2353d4c038c3e89eb25"
now i'm trying find string above ("3d210ad98737def64039a2353d4c038c3e89eb25") 5 words in ruby.
thefunctionineed(params[:words]) # equal "3d210ad98737def64039a2353d4c038c3e89eb25"
source: https://code.google.com/p/crypto-js/#the_hasher_output
just reading source:
https://code.google.com/p/crypto-js/source/browse/tags/3.1.2/src/core.js#181 -->
https://code.google.com/p/crypto-js/source/browse/tags/3.1.2/src/core.js#306 -->
function stringify(wordarray) { // shortcuts var words = wordarray.words; var sigbytes = wordarray.sigbytes; // convert var hexchars = []; (var = 0; < sigbytes; i++) { var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; hexchars.push((bite >>> 4).tostring(16)); hexchars.push((bite & 0x0f).tostring(16)); } return hexchars.join(''); }
then call
stringify(cryptojs.sha1("alextoul"))
sorry don't know ruby enough port that
Comments
Post a Comment