Python hashlib Checksum is different from linux md5sum

Viewed 618

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?

1 Answers
Related