blake3
Version:
BLAKE3 hashing for JavaScript: native Node bindings (where available) and WebAssembly
22 lines • 919 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_instance_1 = require("../node/hash-instance");
const hash_reader_1 = require("../node/hash-reader");
// A buffer we reuse for sending bigints. set_position is synchronous, so
// this just saves creating garbage.
const bigIntBuffer = Buffer.alloc(8);
/**
* A Node.js crypto-like createHash method.
*/
exports.createHash = () => new hash_instance_1.NodeHash(new native_1.default.Hasher(), r => new hash_reader_1.NodeHashReader({
fill: target => r.fill(target),
set_position: position => {
bigIntBuffer.writeBigUInt64BE(position);
r.set_position(bigIntBuffer);
},
}));
//# sourceMappingURL=hash-instance.js.map
;