Node crypto

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2023 Nov 28 12:9
Editor
Edited
Edited
2023 Nov 28 12:10
Refs
Refs
 
import { scryptSync, createCipheriv, createDecipheriv } from 'crypto' const iv = Buffer.alloc(16, 0) const algorithm = 'aes-256-cbc' const key = scryptSync(process.env.SECRET as string, process.env.SALT, 32) export function encode(raw: string) { const cipher = createCipheriv(algorithm, key, iv) const encrypted = cipher.update(raw, 'utf8', 'base64') + cipher.final('base64') return encrypted } export async function decode(encrypted: string) { const deciper = createDecipheriv(algorithm, key, iv) const decrypted = deciper.update(encrypted, 'base64', 'utf8') + deciper.final('utf8') return decrypted }
 
 
 
 
Node js crypto 모듈 / 양방향 암호화
DB에 정보를 암호화해서 저장해야 한다. node js 암호화 모듈 중에서 유명한 crypto 모듈을 사용하기로 ...
Node js crypto 모듈 / 양방향 암호화
 
 
 

Recommendations