import { randomBytes , createCipheriv , createDecipheriv } from 'crypto' ; const algorithm = 'aes-256-ctr' ; export function generateIv ( ) { return randomBytes ( 16 ) ; } export function encrypt ( text , iv , password ) { const cipher = createCipheriv ( algorithm , password , iv ) ; return cipher . update ( text , 'utf8' , 'hex' ) + cipher . final ( 'hex' ) ; } export function decrypt ( text , iv , password ) { const decipher = createDecipheriv ( algorithm , password , iv ) ; return decipher . update ( text , 'hex' , 'utf8' ) + decipher . final ( 'utf8' ) ; }