@accumulators/core
Advanced tools
Comparing version 2.0.4 to 3.0.1
@@ -7,2 +7,3 @@ export type hash = (data: string) => string; | ||
export type HexString = string; | ||
export declare const GENESIS_STRING = "brave new world"; | ||
export declare abstract class IHasher { | ||
@@ -14,2 +15,4 @@ readonly options: HasherOptions; | ||
static byteSize: (str: string) => number; | ||
hashSingle(data: string): string; | ||
getGenesis: () => HexString; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.IHasher = exports.defaultHasherOptions = void 0; | ||
exports.IHasher = exports.GENESIS_STRING = exports.defaultHasherOptions = void 0; | ||
exports.defaultHasherOptions = { | ||
blockSizeBits: 256, | ||
}; | ||
exports.GENESIS_STRING = "brave new world"; | ||
class IHasher { | ||
@@ -14,4 +15,15 @@ options; | ||
static byteSize = (str) => new Blob([str.startsWith("0x") ? str.slice(2) : str]).size; | ||
hashSingle(data) { | ||
return this.hash([data]); | ||
} | ||
getGenesis = () => { | ||
const s = exports.GENESIS_STRING; | ||
let hex = "0x"; | ||
for (let i = 0; i < s.length; i++) { | ||
hex += s.charCodeAt(i).toString(16).padStart(2, "0"); | ||
} | ||
return this.hashSingle(hex); | ||
}; | ||
} | ||
exports.IHasher = IHasher; | ||
//# sourceMappingURL=hasher.js.map |
{ | ||
"name": "@accumulators/core", | ||
"version": "2.0.4", | ||
"version": "3.0.1", | ||
"description": "A collection of TypeScript accumulators packages, each using the core package", | ||
@@ -28,3 +28,3 @@ "keywords": [], | ||
}, | ||
"gitHead": "72c3f1d9380cf8aaed4d33eda81593271c402915" | ||
"gitHead": "46d7d26d5d12dbbe9dfba9e15e7ba375efd0ff49" | ||
} |
Sorry, the diff of this file is not supported yet
10735
170