Last active
September 23, 2019 22:18
-
-
Save paulomcnally/c9e674cfc5b0a950233d to your computer and use it in GitHub Desktop.
Generating PBKDF2 keys in C# and NodeJS
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
public string hash(string pwd,string salt) { | |
Rfc2898DeriveBytes pdb; | |
Byte[] byteValue = System.Text.Encoding.UTF8.GetBytes(salt); | |
pdb = new Rfc2898DeriveBytes(pwd, byteValue, 1333); | |
return Convert.ToBase64String(pdb.GetBytes(32)); | |
} |
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
var crypto = require('crypto'); | |
var hash = function(password, salt) { | |
var pass = crypto.pbkdf2Sync(password, salt, 1333, 32); | |
return new Buffer(pass).toString('base64') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var pass = crypto.pbkdf2Sync(password, salt, 1333, 32);
should be
var pass = crypto.pbkdf2Sync(password, salt, 1333, 32, "sha1");
node v12.4.0