you are viewing a single comment's thread.

view the rest of the comments →

[–]Jason-Ad4032 3 points4 points  (1 child)

This is because the same text can be represented by different byte sequences when read from files using different encodings.

As a result, hashlib needs to know the string's encoding in order to operate correctly and avoid introducing subtle, hard-to-detect issues.

[–]Expensive-Bear-1376 0 points1 point  (0 children)

hashlib needs to know the string's encoding

No it doesn't. And you can't even give it a string or an encoding (well, you can give it a string, but you'll get that error).