UNPKG

@hazae41/ripemd160

Version:

RIPEMD-160 adapter for WebAssembly and JS implementations

39 lines (36 loc) 1.01 kB
import { Copied } from '../../libs/copiable/index.mjs'; 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 Copied(this.inner.clone().digest()); } } function hashOrThrow(bytes) { return new Copied(ripemd160(getBytes(bytes))); } return { Hasher, hashOrThrow }; } export { fromNoble }; //# sourceMappingURL=noble.mjs.map