UNPKG

merkle-tree-lib

Version:

Merkle Tree implementation with BIP340 tagged hash support.

29 lines (28 loc) 798 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Sha256Strategy = void 0; const crypto_1 = require("crypto"); /** * Sha256Strategy - Implementation of HashStrategy using SHA-256 algorithm */ class Sha256Strategy { /** * Calculate a SHA-256 hash for the input data * * @param data - The data to hash * @returns The computed SHA-256 hash as a Buffer */ hash(data) { const dataBuffer = typeof data === 'string' ? Buffer.from(data, 'utf8') : data; return (0, crypto_1.createHash)('sha256').update(dataBuffer).digest(); } /** * Get the algorithm name * * @returns The string "SHA-256" */ getAlgorithmName() { return 'SHA-256'; } } exports.Sha256Strategy = Sha256Strategy;