Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
const ALGORITHM = 'aes-256-cbc'
const BLOCK_SIZE = 16
const contents = Buffer.from(text, 'hex')
const iv = contents.slice(0, BLOCK_SIZE)
const textBytes = contents.slice(BLOCK_SIZE)
const decipher = crypto.createDecipheriv(ALGORITHM, key, iv)
let decrypted = decipher.update(textBytes, 'hex', 'utf8')
decrypted +='utf8')
return decrypted.trim()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment