What does hash.js 's update ('abc') and digest (' hex') mean respectively?

github: https://github.com/indutny/ha.

how to use hash.js:

var hash = require("hash.js")
hash.sha256().update("abc").digest("hex")

question:
what does update ("abc") and digest (" hex") mean respectively?

Dec.09,2021

abc is the string you want to deal with, and hex is the result output format

var hash = require('hash.js')
var res = hash.sha256().update('abc').digest('hex')
console.log(res);

res = hash.sha256().update('123').digest('hex')
console.log(res);

res = hash.sha256().update('123').digest('bin')
console.log(res);

will output

ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3
[ 166,
  101,
  164,
  89,
  32,
  66,
  47,
  157,
  65,
  126,
  72,
  103,
  239,
  220,
  79,
  184,
  160,
  74,
  31,
  63,
  255,
  31,
  160,
  126,
  153,
  142,
  134,
  247,
  247,
  162,
  122,
  227 ]
Menu