Skip to content

Instantly share code, notes, and snippets.

@imdurgadas
Forked from pujansrt/TwoWayHashing.js
Created July 8, 2022 15:04
Show Gist options
  • Save imdurgadas/d7c3be603ce911d5e4f8e875196446ef to your computer and use it in GitHub Desktop.
Save imdurgadas/d7c3be603ce911d5e4f8e875196446ef to your computer and use it in GitHub Desktop.
Two way hashing (JS)
const crypto = require('crypto');
const algorithm = 'aes256';
const salt = '900150983cd24fb0d6963f7d28e17f72';
const cryptoEncoding = 'base64';
const cipher = crypto.createCipher(algorithm, salt);
const encryptedText = cipher.update(text, 'utf8', cryptoEncoding) + cipher.final(cryptoEncoding);
const decipher = crypto.createDecipher(algorithm, salt);
const decryptedText = decipher.update(encryptedText, cryptoEncoding, 'utf8') + decipher.final('utf8');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment