I am trying to calculate the checksum of the string "test" using the python's hashlib module. I am using python3.
In [31]: hobj = hashlib.new('md5')
In [32]: hobj.update('test'.encode("UTF-8"))
In [33]: hobj.hexdigest()
Out[33]: '098f6bcd4621d373cade4e832627b4f6'
But when i am trying the same with the linux md5sum the checksum is totally different from the hashlib's output.
$ echo 'test' | md5sum
d8e8fca2dc0f896fd7cb4cb0031ba249 -
Is there anything wrong with my python code?
Use echo -n 'test'
instead. echo
will output a newline character ("test\n") otherwise.
$ echo -n 'test' | md5sum
098f6bcd4621d373cade4e832627b4f6 -
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With