help
help copied to clipboard
crypto decrypt data got error "Unsupported state or unable to authenticate data"
Details
const cipher = Buffer.from(ciphertext, 'base64')
const authTag = cipher.slice(cipher.length - 16) // Tag长度16
const data = cipher.slice(0, cipher.length - 16)
const decipher = crypto.createDecipheriv('AES-256-GCM', v3key, nonce)
decipher.setAuthTag(authTag)
decipher.setAAD(Buffer.from(associated_data))
return Buffer.concat([
decipher.update(data),
decipher.final(),
]).toString()
I got this error:
Error: Unsupported state or unable to authenticate data
at Decipheriv.final (internal/crypto/cipher.js:172:29)
at Object.decryptNotify
at Object.verifyNotify
Node.js version
Not applicable.Local: v16.16.0 Remote Server: 12
Example code
No response
Operating system
MAC OS Monterey v12.4
Scope
none
Module and version
Not applicable.