Last active
July 8, 2022 15:04
-
-
Save pujansrt/f8615a67e74118b19500a5efc586b99b 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