Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
feed.encrypt2
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 += decipher.final('utf8')
return decrypted.trim()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment