-
-
Save imdurgadas/d7c3be603ce911d5e4f8e875196446ef to your computer and use it in GitHub Desktop.
Two way hashing (JS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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