It provides two functions: .computeValidHeader
and .checkValid
.
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
hashcash CLI can be used to make sure that the output hash is valid or not, or vice versa:
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
~ hashcash -mb20 sametcodes
hashcash stamp: 1:20:220127:sametcodes::HkGGq9bK/lYPdiG7:00000001DrM
hashcash.checkValid("1:20:220127:sametcodes::HkGGq9bK/lYPdiG7:00000001DrM") // true