caesar
Version:
An easy-to-use advanced cryptography library.
33 lines (28 loc) • 627 B
JavaScript
// Generated by CoffeeScript 1.7.1
(function() {
var crypto, sha1;
crypto = require('crypto');
sha1 = require('sha1');
exports.chain = function(value, n, alg) {
var sum, _ref;
if (n == null) {
n = 1;
}
if (alg == null) {
alg = 'sha512';
}
sum = function(val) {
var hash;
if (alg === 'sha1') {
return new Buffer(sha1(val), 'hex');
}
hash = crypto.createHash(alg);
hash.end(val);
return hash.read();
};
while (n !== 0) {
_ref = [n - 1, sum(value)], n = _ref[0], value = _ref[1];
}
return value;
};
}).call(this);