SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function hex(buffer) {
  2.   var hexCodes = []
  3.   var view = new DataView(buffer)
  4.   for (var i = 0; i < view.byteLength; i += 4) {
  5.     var value = view.getUint32(i).toString(16)
  6.     var padding = '00000000'
  7.     var code = (padding + value).slice(-padding.length)
  8.     hexCodes.push(code)
  9.   }
  10.   return hexCodes.join('')
  11. }
  12. async function sha(str) {
  13.   var buffer = new TextEncoder('utf-8').encode(str)
  14.   var hash = await crypto.subtle.digest('SHA-1', buffer)
  15.   return hex(hash)
  16. }
  17. await sha('test')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top