Skip to content

Instantly share code, notes, and snippets.

@jaimegmx8
jaimegmx8 / crypto.js
Created July 10, 2019 22:15
Javascript native sha1 hex
function hex(buffer) {
var hexCodes = []
var view = new DataView(buffer)
for (var i = 0; i < view.byteLength; i += 4) {
var value = view.getUint32(i).toString(16)
var padding = '00000000'
var code = (padding + value).slice(-padding.length)
hexCodes.push(code)
}
return hexCodes.join('')