js-sha256
js-sha256 copied to clipboard
How to pass the input configs Input Encoding, Output Encoding( UTF-8, HMAC )
Hi, I see in your online demo tool, you can adjust Input/Output encoding and hmac Encoding, How can I do it with the hmac function in the code
import {sha256} from 'js-sha256';
console.log(sha256.hmac('key', 'value')) // <= I need to set encoding
Thank you!
This library can accept binary such as bytes array or Uint8Array. See example. You can convert your data to bytes before input. This library can also output bytes and you can convert to other encodings. I use other libraries handle encoding outside this library. For example, I use hi-base64 to handle base64 encoding. You can do something like:
base64.encode(sha256.digest(''))