UNPKG

@hazae41/ripemd160

Version:

RIPEMD-160 adapter for WebAssembly and JS implementations

41 lines (37 loc) 1.05 kB
'use strict'; var index = require('../../libs/copiable/index.cjs'); function fromNoble(noble) { const { ripemd160 } = noble; function getBytes(bytes) { return "bytes" in bytes ? bytes.bytes : bytes; } class Hasher { inner; constructor(inner) { this.inner = inner; } [Symbol.dispose]() { } static create(inner) { return new Hasher(inner); } static createOrThrow() { return new Hasher(ripemd160.create()); } cloneOrThrow() { return new Hasher(this.inner.clone()); } updateOrThrow(bytes) { this.inner.update(getBytes(bytes)); return this; } finalizeOrThrow() { return new index.Copied(this.inner.clone().digest()); } } function hashOrThrow(bytes) { return new index.Copied(ripemd160(getBytes(bytes))); } return { Hasher, hashOrThrow }; } exports.fromNoble = fromNoble; //# sourceMappingURL=noble.cjs.map