blake3
Version:
BLAKE3 hashing for JavaScript: native Node bindings (where available) and WebAssembly
27 lines • 849 B
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const native_1 = __importDefault(require("./native"));
const hash_fn_1 = require("../base/hash-fn");
/**
* @hidden
*/
exports.normalizeInput = (input, encoding) => {
if (input instanceof Buffer) {
return input;
}
if (typeof input === 'string') {
return Buffer.from(input, encoding);
}
return Buffer.from(input);
};
/**
* Returns a blake3 hash of the input, returning the binary hash data.
*/
function hash(input, { length = hash_fn_1.defaultHashLength } = {}) {
return native_1.default.hash(exports.normalizeInput(input), length);
}
exports.hash = hash;
//# sourceMappingURL=hash-fn.js.map
;