Sha256 With Byte[32] Using CryptoJS?
Using CryptoJS i got as a result a byte[8] when I need a 32 one, this code exactly: CryptoJS.SHA256(word); How to get the 32?
Solution 1:
This feels a bit convoluted, but I don't have a lot of experience with CryptoJS so perhaps there's a solution that requires less steps:
const CryptoJS = require('crypto-js');
let hash = CryptoJS.SHA256('hello world');
let buffer = Buffer.from(hash.toString(CryptoJS.enc.Hex), 'hex');
let array = new Uint8Array(buffer);
If you need a proper JS array (one for which Array.isArray
returns true
), you can use this:
let array = Array.from( new Uint8Array(buffer) );
Solution 2:
CryptoJS.SHA256(word).toString()
Post a Comment for "Sha256 With Byte[32] Using CryptoJS?"