Skip to content

Instantly share code, notes, and snippets.

@chrisumbel
Forked from PalmerEk/dotNetPassHash
Created September 4, 2011 16:13
Show Gist options
  • Select an option

  • Save chrisumbel/1193085 to your computer and use it in GitHub Desktop.

Select an option

Save chrisumbel/1193085 to your computer and use it in GitHub Desktop.
ASP.NET Membership password hash for Node.js
var crypto = require('crypto');
console.log(dotnet_membership_password_hash("welcome1", "qkI2wRPSW7Y4ArqWkfHm5g==")); // W25/z6MAywBax7DITuKgSmsXua4=
function dotnet_membership_password_hash(pass, salt)
{
var bytes = new Buffer(pass || '', 'ucs2');
var src = new Buffer(salt || '', 'base64');
var dst = new Buffer(src.length + bytes.length);
src.copy(dst, 0, 0, src.length);
bytes.copy(dst, src.length, 0, bytes.length);
return crypto.createHash('sha1').update(dst).digest('base64');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment