Last active
January 26, 2023 13:24
-
-
Save PalmerEk/1191651 to your computer and use it in GitHub Desktop.
ASP.NET Membership password hash for Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great job! So glad you were able to find the solution.