@gideo-llc/backblaze-b2-upload-any
Version:
An intelligent upload function to be used with the backblaze-b2 module
18 lines (14 loc) • 478 B
JavaScript
try {
const asyncHash = require('@ronomon/crypto-async').hash;
const { promisify } = require('./promise-utils');
const promiseHash = promisify(asyncHash);
module.exports = async buffer =>
(await promiseHash('sha1', buffer)).toString('hex');
} catch (err) {
const crypto = require('crypto');
module.exports = buf => {
const h = crypto.createHash('sha1');
h.update(buf);
return Promise.resolve(h.digest('hex'));
};
}