1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const bcrypto_1 = require("bcrypto");
|
4 | class HashAlgorithms {
|
5 | static ripemd160(buffer) {
|
6 | return bcrypto_1.RIPEMD160.digest(this.bufferize(buffer));
|
7 | }
|
8 | static sha1(buffer) {
|
9 | return bcrypto_1.SHA1.digest(this.bufferize(buffer));
|
10 | }
|
11 | static sha256(buffer) {
|
12 | if (Array.isArray(buffer)) {
|
13 | let sha256 = bcrypto_1.SHA256.ctx;
|
14 | sha256.init();
|
15 | for (const element of buffer) {
|
16 | sha256 = sha256.update(element);
|
17 | }
|
18 | return sha256.final();
|
19 | }
|
20 | return bcrypto_1.SHA256.digest(this.bufferize(buffer));
|
21 | }
|
22 | static hash160(buffer) {
|
23 | return bcrypto_1.Hash160.digest(this.bufferize(buffer));
|
24 | }
|
25 | static hash256(buffer) {
|
26 | return bcrypto_1.Hash256.digest(this.bufferize(buffer));
|
27 | }
|
28 | static bufferize(buffer) {
|
29 | return buffer instanceof Buffer ? buffer : Buffer.from(buffer);
|
30 | }
|
31 | }
|
32 | exports.HashAlgorithms = HashAlgorithms;
|
33 |
|
\ | No newline at end of file |