Closed GoogleCodeExporter closed 8 years ago
The output you would get from any language or application depends on how it
converts a character into bytes. Python and the online hash calculators are
probably treating your input as Latin1. But JavaScript strings are Unicode, and
every character could be one of more than a million possible characters. To
accommodate all those possible characters, CryptoJS by default will convert
strings to UTF-8 bytes. But if you want to get Latin1 bytes instead, you can do
that too.
var hash = CryptoJS.SHA256( CryptoJS.enc.Latin1.parse('\xee') ).toString();
Original comment by Jeff.Mott.OR
on 11 Feb 2013 at 6:03
Original comment by Jeff.Mott.OR
on 12 Feb 2013 at 8:21
[deleted comment]
I don't get the explanation.
var s = '\xee';
s.length; /* => 1 */
'0x' + s.charCodeAt(0); /* => "0xee" */
.. looks good, behaves like binary data.
So if CryptoJS.SHA256 is somehow converting it to UTF-8 before the hashing (and
then back to bytes?), it is doing nonsense, in my humble opinion.
Original comment by michal.b...@gmail.com
on 19 Sep 2014 at 2:54
Original issue reported on code.google.com by
sergiy.g...@gmail.com
on 11 Feb 2013 at 12:57