UNPKG

slpjs-regtest-testing

Version:

Simple Ledger Protocol (SLP) JavaScript Library

22 lines (21 loc) 698 B
"use strict"; exports.__esModule = true; exports.Crypto = void 0; var crypto_js_1 = require("crypto-js"); var Crypto = /** @class */ (function () { function Crypto() { } Crypto.sha256 = function (buffer) { var words = crypto_js_1["default"].enc.Hex.parse(buffer.toString("hex")); var hash = crypto_js_1["default"].SHA256(words); return Buffer.from(hash.toString(crypto_js_1["default"].enc.Hex), "hex"); }; Crypto.hash256 = function (buffer) { return this.sha256(this.sha256(buffer)); }; Crypto.txid = function (buffer) { return Buffer.from(this.hash256(buffer).reverse()); }; return Crypto; }()); exports.Crypto = Crypto;