Skip to content

Instantly share code, notes, and snippets.

View hongphuc5497's full-sized avatar
🐧
Focusing

Hong Phuc hongphuc5497

🐧
Focusing
View GitHub Profile
@hongphuc5497
hongphuc5497 / README.md
Created November 8, 2022 05:53 — forked from twolfson/README.md
Audit logging via sequelize

We prefer to have audit logging in our services that leverage databases. It gives us clarity into sources of where ACL issues might originate as well as gives us a general timeline of activity in our application.

Audit logging is tedious to set up so this gist contains our latest iteration of audit logging support for a sequelize based service.

@hongphuc5497
hongphuc5497 / encryption.js
Created August 16, 2022 08:36 — forked from vlucas/encryption.js
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);