sjcl icon indicating copy to clipboard operation
sjcl copied to clipboard

sha256 and utf8string from bit error

Open ngoclinhhoang opened this issue 6 years ago • 1 comments

Hi guys,

I'm trying to get the hash sha256 value with utf8 string format. I expect [email protected] will be come c0f50b4ab8bdd7bae3a6aff8278d3e96b07d0957541fdc1d4ad8c09680e00d5c with this line of code:

sjcl.codec.utf8String.fromBits(sjcl.hash.sha256.hash("[email protected]"));

But, I receive this error message instead: sjcl.js:8 Uncaught TypeError: Cannot read property 'length' of undefined at Object.bitLength (sjcl.js:8) at sjcl.hash.sha256.update (sjcl.js:18)

Could you please help me to get the right value? Thank you Best Linh

ngoclinhhoang avatar May 21 '19 16:05 ngoclinhhoang

Your expected output is hexadecimal, not UTF-8. Change utf8String to hex.

robyoder avatar May 22 '19 15:05 robyoder