Closed mastilver closed 8 years ago
$ credential hash "test" --work 0.01
{"salt":"YTMazeNKJ12xRowgWSNFuiis4igrd5Ic4l202RMnh+9ikgfWhliTXgSLM8FzlzSfAqydVJO8j8UQhOHrM+YT8jJV","hash":"c2NilQ1y+tuFh/z65dG94J703cCWFdW0l5MqY4As8O9U36xbaIbS89R3JrlGPagUFCw1qJrPte4lGB2DH64GyHNl","keyLength":66,"hashMethod":"pbkdf2","iterations":2454}
$ credential verify '{"salt":"YTMazeNKJ12xRowgWSNFuiis4igrd5Ic4l202RMnh+9ikgfWhliTXgSLM8FzlzSfAqydVJO8j8UQhOHrM+YT8jJV","hash":"c2NilQ1y+tuFh/z65dG94J703cCWFdW0l5MqY4As8O9U36xbaIbS89R3JrlGPagUFCw1qJrPte4lGB2DH64GyHNl","keyLength":66,"hashMethod":"pbkdf2","iterations":2454}' "test"
Verified
Could it be an escaping issue? What is your result from:
$ TEST=$(credential hash test --work 0.01)
$ credential verify $TEST test
I've just tried that:
verify '{"hash":"Bo8VvwqqJu0jC6aji9t/CBjFT52sYAaMpfuOZ88vIqB8ORhpGS4V21gSAYHM+GH3+IbZTkh8VnnMego1jgt6xga0","salt":"vnhth+OOghJy+rfdEddukuAZjthcM6sDPoeSfLWOoVpFctjEgsqAlJXVgI2QyIKizMllCY9hHtXjXPSfrwqtN/lW","keyLength":66,"hashMethod":"pbkdf2","iterations":245737}' password
I got back; [Error: Couldn't parse stored hash.]
I'm on a windows computer right now, I will try later on *unix
Could you try logging the input when doing a verify
? Somehow the JSON is missing or corrupted.
so I've put: console.log(typeof hash, hash);
It displays me:
string {hash:Bo8VvwqqJu0jC6aji9t/CBjFT52sYAaMpfuOZ88vIqB8ORhpGS4V21gSAYHM+GH3+IbZTkh8VnnMego1jgt6xga0,salt:vnhth+OOghJy+rfdEddukuAZjthcM6sDPoeSfLWOoVpFctjEgsqAlJXVgI2QyIKizMllCY9hHtXjXPSfrwqtN/lW,keyLength:66,hashMethod:pbkdf2,iterations:245737}
Could it be an escaping issue?
Must be that... Can you think of a way to fix it without breaking unix (I'm guessing it's working fine on unix)
Weird.. That string is not valid JSON because the "
are missing. To me it seems like either your shell or something in between is doing bad stuff. At least I don't think it is a "code issue".
Could you try putting in something else with a "
and see how it is received in Node? I don't have a Windows VM available atm. so I can't really debug.
yep it's a windows issue (yet another one... ): http://stackoverflow.com/questions/7760545/cmd-escape-double-quotes-in-parameter I should have check that earlier
:+1:
this work:
echo -n "my password" | credential hash - | credential verify - "my password"
But if I do:
credential hash password
and then:
credential verify <the previous output> password
It's throwing me:Unexpected token ':"w6iqo4XwaKPzWn7B541EW+kWeVmJ9bMMv3WNMPPutWuwwSdJecntnXDBFw Xc+MO/dtAFnZKkdg+bBPIjJOqUpKGJ"' in expression or statement.
I can't figure out why...