mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
23 lines
487 B
JavaScript
23 lines
487 B
JavaScript
(function() {
|
|
'use strict';
|
|
|
|
var crypto = require('crypto');
|
|
|
|
module.exports = function(password, algo) {
|
|
var result, sha;
|
|
|
|
if (!password)
|
|
throw Error('password could not be empty!');
|
|
|
|
if (!algo)
|
|
algo = 'sha512WithRSAEncryption';
|
|
|
|
sha = crypto.createHash(algo);
|
|
|
|
sha.update(password);
|
|
result = sha.digest('hex');
|
|
|
|
return result;
|
|
};
|
|
|
|
})();
|