sha 256 Encrypt code (from document)
function hmacEncrypt(r) {
let str = r.uri.split("/", 2)
return require('crypto').createHash('sha256', 'key')
.update(str)
.digest('base64url');
}
I want to use njs to decode aes256, base64 encoded string. However, the official njs document only shows the encrypt method. Is there a way to decode or encode aes256? Can I help you?
For the aes256, you can do something like:
The
initVector
is to provide the initial state of the algorithm, you can change it to whatever you want but it should be an array of exactly 16 bytes, then just simply use those functions:The
securityKey
key is the password that will be used to encrypt and decrypt the string, it should be an array of exactly 32 bytes, change it to whatever you want!