Closed luzfcb closed 8 years ago
You can just loop through the bytes and print them as hex.
function arrayBuffer_to_hex(array_b) {
var hex_string = "";
var bytes = new Uint8Array(array_b);
for(var i = 0; i < bytes.length; i++){
var hex_i = bytes[i].toString(16);
hex_string += hex_i.length === 1 ? "0" + hex_i : hex_i;
}
return hex_string;
}
Thank you for giving of your time to answer this question.
A few minutes before you answer, I found this: https://chromium.googlesource.com/chromium/blink/+/master/LayoutTests/crypto/subtle/resources/common.js#20
First, thanks for the great examples. I'm still a novice with javascript. I'm trying to mix FileAPI with webcrypto
I would like to select a file in an input type="file" and get the same hash it would obtain when executing sha1sum via terminal
My current doubt is how transform ArrayBuffer get HEX in same output HEX format of sha1sum Linux command.
my test code is this: