Trying to figure out why my base64 sha1’s are different.
I get
Password ‘a’ Result ‘hvfkN/qlp/zhXR3cuerq6jd2Z7g=’
When using my java function. I can verify that using some random online tools.
However when I try to verify using the command line and openssl
echo a | openssl dgst -binary -sha1 | openssl base64
I get
P3hoUOOHVQ/auDbtfm3Igd4jABs=
That maybe it was utf8/bash thing, so I tried
echo 'a' | iconv --from-code=ISO-8859-1 --to-code=UTF-8 | openssl dgst -binary -sha1 | openssl base64
Same result.
What am I missing?
Edit:
Sites that verify my original result
http://www.tools4noobs.com/online_php_functions/sha1/ to calculate hex sha1
86f7e437faa5a7fce15d1ddcb9eaeaea377667b8
Convert hex to base64
http://tomeko.net/online_tools/hex_to_base64.php?lang=en
hvfkN/qlp/zhXR3cuerq6jd2Z7g=
echoappends a newline, which will be included in the digest computation; tryprintfinstead. Also be wary of other parts of the pipeline adding extraneous newlines or other characters.