qruqs
1
I have a puzzle for those more cunning than I am.
$ cksum -a sha512 <<< "test"
SHA512 (-) = 0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123
$ python -c "import hashlib;print(hashlib.sha512(b'test').hexdigest())"
ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff
Are the two implementations different, or am I doing something silly?
(Hmmm, there is no tag for ‘coreutils’ to which cksum belongs and I don’t seem to be able to add one either. Oh, well…)
Strit
2
maybe the cksum
line also takes the double quotes as part of the string to hash, while the python line just does test
?
1 Like
When they generate different output - they are different
Perhaps - comparing apple to orange - they are shaped similar … content is different
if it can be of any help - at least the same utility provide the same result across systems
$ cksum -a sha512 <<< test
SHA512 (-) = 0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123
$ python -c "import hashlib;print(hashlib.sha512(b'test').hexdigest())"
ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff
1 Like
Zesko
4
Do not forget to add a line break \n
.
python -c "import hashlib;print(hashlib.sha512(b'test\n').hexdigest())"
0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123
$ cksum -a sha512 <<< "test"
SHA512 (-) = 0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123
Both are the same.
3 Likes
qruqs
5
Wow! How could I miss that? Thanks! 
system
Closed
6
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.