diff --git a/lib/server/auth.js b/lib/server/auth.js index da052d51..c2dd9065 100644 --- a/lib/server/auth.js +++ b/lib/server/auth.js @@ -32,11 +32,11 @@ var auth = httpAuth.basic({ realm: 'Cloud Commander' }, function (username, password, callback) { - var hash, + var hash, sha, name = config('username'), pass = config('password'), equal = username === name, - sha = crypto.createHash('sha512WithRSAEncryption'); + algo = 'sha512WithRSAEncryption'; if (!oldPass) oldPass = pass; @@ -47,13 +47,14 @@ if (!equal) username === oldName; + sha = crypto.createHash(algo); sha.update(password); hash = sha.digest('hex'); equal = pass === hash && equal; if (!equal) { - sha = crypto.createHash('sha512WithRSAEncryption'); + sha = crypto.createHash(algo); sha.update(oldPass); hash = sha.digest('hex'); equal = pass === hash && equal;