Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 1.19 KB

readme.md

File metadata and controls

40 lines (28 loc) · 1.19 KB

Hashcash ― JavaScript implementation

It provides two functions: .computeValidHeader and .checkValid.

Usage

const Hashcash = require('./hashcash')
const hashcash = new Hashcash({resource: "sametcodes"});

hashcash.computeValidHeader() // 1:20:220127:sametcodes::M5gLmflPN4C18sUv:0000001gSA
hashcash.checkValid("1:20:220127:sametcodes::M5gLmflPN4C18sUv:0000001gSA") // true

Testing

hashcash CLI can be used to make sure that the output hash is valid or not, or vice versa:

Checking hashcash.js output on hashcash-cli

hashcash.computeValidHeader() // 1:20:220127:sametcodes::MS4wMzAyNjgzMjMyNzQ4ODllKzMwOA==:MTAwMTAxMTAxMDExMTA=
~ hashcash -cdb20 -r sametcodes 1:20:220127:sametcodes::MS4wMzAyNjgzMjMyNzQ4ODllKzMwOA==:MTAwMTAxMTAxMDExMTA=
matched stamp: 1:20:220127:sametcodes::MS4wMzAyNjgzMjMyNzQ4ODllKzMwOA==:MTAwMTAxMTAxMDExMTA=
check: ok

Checking hashcash-cli hash on hashcash.js

~ hashcash -mb20 sametcodes
hashcash stamp: 1:20:220127:sametcodes::HkGGq9bK/lYPdiG7:00000001DrM
hashcash.checkValid("1:20:220127:sametcodes::HkGGq9bK/lYPdiG7:00000001DrM") // true