Skip to content

Instantly share code, notes, and snippets.

View GGonryun's full-sized avatar
🧗
Hello World!

Miguel Campos GGonryun

🧗
Hello World!
View GitHub Profile
@GGonryun
GGonryun / secrets.ts
Created July 10, 2025 21:20
Key Rotation Secrets Library
import crypto from 'node:crypto';
import { CryptographyError } from './errors';
const ALGORITHM = 'aes-256-gcm';
const IV_LENGTH = 12; // GCM standard
const LATEST_KEY = 'v1'; // Current version of the encryption key
export namespace secrets {
const keys = {
v1: Buffer.from(process.env.ENCRYPTION_KEY_V1!, 'hex') // Must be 32 bytes