Skip to content

Instantly share code, notes, and snippets.

@PalmerEk
Last active January 26, 2023 13:24
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save PalmerEk/1191651 to your computer and use it in GitHub Desktop.
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
Author

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

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