The specification says that the salt option is optional:
optionally, a $ sign followed by the (encoded) salt value;
However, this package requires it to be defined to output the hash.
Here's an example:
#!/usr/bin/env node
const crypto = require('node:crypto')
const phc = require('@phc/format')
const hbuf = crypto.createHash('sha256').update('asdf').digest()
console.log(phc.serialize({
id: 'sha256',
// salt: Buffer.alloc(0),
hash: hbuf,
}))
I expect this to print $sha256$8OTC92xYkW7CWPJGhRvqCR0U1CR6L8PhhpRGGxgW4Ts, but it only prints $sha256.
I need to specify a salt to get the hash to print. (Also note that un-commenting the salt line will serialize with a zero-length salt, i.e., $sha256$$ prefix.)
The specification says that the
saltoption is optional:However, this package requires it to be defined to output the hash.
Here's an example:
I expect this to print
$sha256$8OTC92xYkW7CWPJGhRvqCR0U1CR6L8PhhpRGGxgW4Ts, but it only prints$sha256.I need to specify a
saltto get thehashto print. (Also note that un-commenting thesaltline will serialize with a zero-length salt, i.e.,$sha256$$prefix.)