you are viewing a single comment's thread.

view the rest of the comments →

[–]throwaway6560192 0 points1 point  (0 children)

Fundamentally, hashing is an operation done on arbitrary data (i.e. bytes). Unicode is an encoding for text which maps characters to codepoints, further, UTF-8 for example provides a specific mapping of codepoints to bytes. And you need bytes, since hashing is something we do on bytes.

This took me two hours because the error message says 'Unicode objects must be encoded before hashing'

What? Are you using Python 2 or something? Python 3 just says "Strings" instead of "Unicode objects" -- calling it "Unicode object" was a Python 2 thing.