| Server IP : 82.208.35.60 / Your IP : 216.73.216.89 Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31 System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64 User : studiokobylisy_cz ( 1008) PHP Version : 7.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/studiokobylisy_cz/www/wp-content/themes/studiokobylisy/node_modules/hasha/ |
Upload File : |
'use strict';
var fs = require('fs');
var crypto = require('crypto');
var isStream = require('is-stream');
var Promise = require('pinkie-promise');
var hasha = module.exports = function (input, opts) {
opts = opts || {};
var outputEncoding = opts.encoding || 'hex';
if (outputEncoding === 'buffer') {
outputEncoding = undefined;
}
var hash = crypto.createHash(opts.algorithm || 'sha512');
var update = function (buf) {
var inputEncoding = typeof buf === 'string' ? 'utf8' : undefined;
hash.update(buf, inputEncoding);
};
if (Array.isArray(input)) {
input.forEach(update);
} else {
update(input);
}
return hash.digest(outputEncoding);
};
hasha.stream = function (opts) {
opts = opts || {};
var outputEncoding = opts.encoding || 'hex';
if (outputEncoding === 'buffer') {
outputEncoding = undefined;
}
var stream = crypto.createHash(opts.algorithm || 'sha512');
stream.setEncoding(outputEncoding);
return stream;
};
hasha.fromStream = function (stream, opts) {
if (!isStream(stream)) {
return Promise.reject(new TypeError('Expected a stream'));
}
opts = opts || {};
return new Promise(function (resolve, reject) {
stream
.on('error', reject)
.pipe(hasha.stream(opts))
.on('error', reject)
.on('finish', function () {
resolve(this.read());
});
});
};
hasha.fromFile = function (fp, opts) {
return hasha.fromStream(fs.createReadStream(fp), opts);
};
hasha.fromFileSync = function (fp, opts) {
return hasha(fs.readFileSync(fp), opts);
};