Skip to content

Instantly share code, notes, and snippets.

@PalmerEk
Last active June 28, 2025 03:43
Show Gist options
  • Select an option

  • Save PalmerEk/1191651 to your computer and use it in GitHub Desktop.

Select an option

Save PalmerEk/1191651 to your computer and use it in GitHub Desktop.
ASP.NET Membership password hash for Node.js
See updated reply by OpenSpacesAndPlaces
https://gist.github.com/PalmerEk/1191651?permalink_comment_id=4449026#gistcomment-4449026
/////////////////////////////////////////////////////////////
// ORIGINAL/OLD for posterity
/////////////////////////////////////////////////////////////
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');
}
@PalmerEk
Copy link
Copy Markdown
Author

Great job! So glad you were able to find the solution.

@bpatton00
Copy link
Copy Markdown

absolute life saver, was getting crushed by this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment