문제

I run echo lol | md5 in Mac Terminal and it returns: 59bcc3ad6775562f845953cf01624225

But then I run print hashlib.md5("lol").hexdigest() in python 2.7 and I get: 9cdfb439c7876e703e307864c9167a15

What am I doing wrong?

도움이 되었습니까?

해결책

echo appends a newline at the end by default, so it will give a different hash.

In python, with the newline ending

>>> print hashlib.md5("lol\n").hexdigest()
59bcc3ad6775562f845953cf01624225

Standard echo command, with the newline ending omitted.

$ echo -n lol | md5sum -
9cdfb439c7876e703e307864c9167a15  -
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top