0

I know the string "03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd" generates the SHA-256 hash 4c0b2d2f119a09b607cb273a745b2b0430d5192e0c4e536f932be5d1a6be5883 using https://privatekeys.pw/calc

However the command line

┌──(root㉿localhost)-[/home/kali]
└─# echo "03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd" | sha256sum
92dbdf5d8231512f44fff4544d41b334ff8042db23e4dee454d4b0b61121f3ff  -

┌──(root㉿localhost)-[/home/kali]
└─# echo -n  "03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd" | sha256sum
0f5b284caf3ab192b20f849b7b53d5877b83cae8b7bc617dc34104e6688ed45e  -

┌──(root㉿localhost)-[/home/kali]
└─# sha256sum <<< 03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd
92dbdf5d8231512f44fff4544d41b334ff8042db23e4dee454d4b0b61121f3ff  -

┌──(root㉿localhost)-[/home/kali]
└─# sha256sum hash
92dbdf5d8231512f44fff4544d41b334ff8042db23e4dee454d4b0b61121f3ff  hash

Generates a different hash. What am I missing?

0

1 Answer 1

3

I know the string "03a3... " generates the SHA-256 hash 4c0b... using https://privatekeys.pw/calc

The string does not result in this hash. What you likely mean is not to treat the string as it is, but as hex-encoded binary data. This means you need to convert the hex string to binary first before doing the hash, like this:

echo 03a3... | xxd -r -p - | sha256sum
4
  • What about RIPEMD-160 command line hashing, when I hash the string "4c0b2d2f119a09b607cb273a745b2b0430d5192e0c4e536f932be5d1a6be588" in privatekeys.pw/calc it gives the output hash "9a1c78a507689f6f54b847ad1cef1e614ee23f1e" how can I do this in command line Commented Jun 5, 2023 at 8:35
  • @AvirilSmith: Your original question is answered. Please don't ask new questions in the comment. But in short: openssl dgst will provide what you need. Commented Jun 5, 2023 at 8:59
  • Yh I won't next time, but it's giving different output when I use the openssl command that's why Commented Jun 5, 2023 at 11:36
  • @AvirilSmith: it works if you a) also convert it to binary first using xxd b) don't have a typo in the string (missing final 3): echo 4c0b2d2f119a09b607cb273a745b2b0430d5192e0c4e536f932be5d1a6be5883 | xxd -r -p - | openssl dgst -ripemd160 Commented Jun 5, 2023 at 13:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .