Skip to content

Instantly share code, notes, and snippets.

@MatthieuLemoine
Created September 13, 2016 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatthieuLemoine/2d00582ed7d46b806ff9e370066b274b to your computer and use it in GitHub Desktop.
Save MatthieuLemoine/2d00582ed7d46b806ff9e370066b274b to your computer and use it in GitHub Desktop.
Verify hash on CouchDB
const crypto = require('crypto');
const basicAuthToken = 'Yaaadfg9obGk6YTmleDI0ZGJiZg==';
const authToken = new Buffer(basicAuthToken, 'base64').toString('ascii');
const [username, password] = authToken.split(':');
const derivedKey = 'YaaadYaaadf569da661ac474db5d229547595a33';
const salt = 'YaaadfYaaadfd91037e9aa67e946f692';
const iterations = 10;
crypto.pbkdf2(password, salt, iterations, derivedKey.length / 2, (err, verify) => {
if (err) {
console.error(err);
} else {
console.log(verify.toString('hex'));
console.log(verify.toString('hex') === derivedKey);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment