UNPKG

@sentre/craco-plugins

Version:
12 lines (11 loc) 704 B
"use strict"; function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } var nacl = require('tweetnacl'); function hash(buf) { if (typeof buf === 'string') buf = Buffer.from(buf, 'utf8');else if (Buffer.isBuffer(buf)) buf = buf;else throw new Error("Type of ".concat(_typeof(buf), " is not valid to hash input")); var hash = nacl.hash(buf); return Buffer.from(hash).toString('hex'); } module.exports = { hash: hash };