Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v4
Expand All @@ -20,4 +20,4 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm test
- run: npm test
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webrisk-hash",
"version": "2.0.3",
"version": "3.0.0",
"description": "",
"main": "index.js",
"type": "module",
Expand Down
6 changes: 3 additions & 3 deletions test/truncatedSHA256Prefix.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test("len4", (t) => {
// Example B1 from FIPS-180-2
const input1 = "abc";
const output1 = truncatedSha256Prefix(input1, 32);
const expected1 = new Buffer([0xba, 0x78, 0x16, 0xbf]);
const expected1 = new Buffer.from([0xba, 0x78, 0x16, 0xbf]);
assert.equal(output1.length, 4); // 4 bytes == 32 bits
for (let i = 0; i < output1.length; i++)
assert.equal(output1[i], expected1[i]);
Expand All @@ -16,7 +16,7 @@ test("len6", (t) => {
// Example B2 from FIPS-180-2
const input2 = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
const output2 = truncatedSha256Prefix(input2, 48);
const expected2 = new Buffer([0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06]);
const expected2 = new Buffer.from([0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06]);
assert.equal(output2.length, 6);
for (let i = 0; i < output2.length; i++)
assert.equal(output2[i], expected2[i]);
Expand All @@ -26,7 +26,7 @@ test("len12", (t) => {
// Example B3 from FIPS-180-2
const input3 = Array(1000000).fill("a").join(""); // 'a' repeated a million times
const output3 = truncatedSha256Prefix(input3, 96);
const expected3 = new Buffer([
const expected3 = new Buffer.from([
0xcd, 0xc7, 0x6e, 0x5c, 0x99, 0x14, 0xfb, 0x92, 0x81, 0xa1, 0xc7, 0xe2,
]);
assert.equal(output3.length, 12);
Expand Down
2 changes: 1 addition & 1 deletion webrisk-hash.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
const webrisk = require("webrisk-hash");
import { getPrefixMap } from "webrisk-hash";
const res = webrisk.getPrefixMap(process.argv[2]);
console.log(res.map(l => `${l[0]} ${l[1].toString("hex")}`).join('\n'));
Loading