apache-md5
Advanced tools
Comparing version 1.0.0 to 1.0.2
@@ -59,5 +59,13 @@ // Crypto module import. | ||
encrypt: function(password, salt) { | ||
var magic = ''; | ||
if (salt.split('$')[1] === '1') { | ||
magic = '$1$' | ||
} else { | ||
magic = '$apr1$' | ||
} | ||
salt = MD5.getSalt(salt); | ||
var ctx = password + "$apr1$" + salt; | ||
var ctx = password + magic + salt; | ||
var final = crypto.createHash('md5').update(password + salt + password).digest("binary"); | ||
@@ -102,3 +110,3 @@ | ||
return "$apr1$" + salt + "$" + MD5.getPassword(final); | ||
return magic + salt + "$" + MD5.getPassword(final); | ||
} | ||
@@ -105,0 +113,0 @@ }; |
{ | ||
"name": "apache-md5", | ||
"description": "Node.js module for Apache style password encryption using md5.", | ||
"version": "1.0.0", | ||
"version": "1.0.2", | ||
"author": "Gevorg Harutyunyan (http://github.com/gevorg)", | ||
@@ -28,3 +28,3 @@ "maintainers": [ | ||
"devDependencies": { | ||
"nodeunit": "0.8.1" | ||
"nodeunit": "0.9.1" | ||
}, | ||
@@ -35,5 +35,5 @@ "engines": { | ||
"scripts": { | ||
"test": "./node_modules/nodeunit/bin/nodeunit tests/*" | ||
"test": "node ./node_modules/nodeunit/bin/nodeunit tests" | ||
}, | ||
"keywords": ["node", "apache", "md5", "password", "htpasswd"] | ||
} |
@@ -25,7 +25,9 @@ # apache-md5 | ||
var encryptedPassword = md5("mypass"); // Encrypting password using apache's md5 algorithm. | ||
// Encrypting password using apache's md5 algorithm. | ||
var encryptedPassword = md5("mypass"); | ||
console.log(md5("mypass", encryptedPassword) == encryptedPassword); // Should print true. | ||
console.log(md5("notmypass", encryptedPassword) == encryptedPassword); // Should print false. | ||
... | ||
// Should print true. | ||
console.log(md5("mypass", encryptedPassword) == encryptedPassword); | ||
// Should print false. | ||
console.log(md5("notmypass", encryptedPassword) == encryptedPassword); | ||
``` | ||
@@ -58,3 +60,3 @@ | ||
Copyright (c) 2013 Gevorg Harutyunyan | ||
Copyright (c) 2015 Gevorg Harutyunyan | ||
@@ -61,0 +63,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
8578
108
77