Skip to content

Instantly share code, notes, and snippets.

@woubuc
Last active May 20, 2020 13:26
Show Gist options
  • Save woubuc/ff512566616ca1867aadb13e66e346fa to your computer and use it in GitHub Desktop.
Save woubuc/ff512566616ca1867aadb13e66e346fa to your computer and use it in GitHub Desktop.
const crypto = require('crypto');
// Generate salt from player name
let hasher = crypto.createHash('sha1');
let salt = hasher.update(name).digest('base64');
// Generate pbkdf2 hash from ID using generated salt
crypto.pbkdf2(id, new Buffer(salt), 1000, 24, 'sha1', (err, key) => {
let passwordHash = key.toString('hex');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment