Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass the input configs Input Encoding, Output Encoding( UTF-8, HMAC ) #47

Open
thangpqgm opened this issue Sep 5, 2024 · 1 comment

Comments

@thangpqgm
Copy link

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

image

Thank you!

@emn178
Copy link
Owner

emn178 commented Sep 6, 2024

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(''))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants