Closed GoogleCodeExporter closed 9 years ago
When you pass a string to a hasher, it's converted to bytes using UTF-8. That's
to ensure foreign characters are not clipped. Since you're working with binary
data, you'll want to convert the string to bytes using Latin1.
sha256.update(CryptoJS.enc.Latin1.parse(evt.target.result));
Original comment by Jeff.Mott.OR
on 24 Dec 2012 at 6:09
Thanks Jeff! That fixed it.
Original comment by ucrkart...@gmail.com
on 24 Dec 2012 at 3:12
Original comment by Jeff.Mott.OR
on 26 Dec 2012 at 2:41
I'm using the following javascript:
<script type="text/javascript">
function HashBinary(file) {
var sha256 = CryptoJS.algo.SHA256.create();
sha256.update(CryptoJS.enc.Latin1.parse(file));
var hash = sha256.finalize();
return hash;
}
</script>
Parameter "file" is an object from a ZIP file got with
Scripting.FileSystemObject.GetFile in HTA/ASP script or stream from
ADODB.Stream in same script.
In bove situations the hash is the same, but not the expected one.
And the line "sha256.update" in javascript has no effect. Same wrong hash is
calcalated.
Am I doing something wrong?
Original comment by reinaldo...@gmail.com
on 29 Jan 2013 at 5:12
Hi, Reinaldo. Please provide a full page/script that I can use to reproduce the
issue. Also let me know what browser and OS you're on, as well as what output
you expect and what you see instead. Thanks.
Original comment by Jeff.Mott.OR
on 29 Jan 2013 at 5:29
Original issue reported on code.google.com by
ucrkart...@gmail.com
on 24 Dec 2012 at 5:56