Unable to get a sha256 hash of a string
23,410
Use utf-8
encoding:
hs = hashlib.sha256(get_some_string().encode('utf-8')).hexdigest()
To get more information read documentation.
Author by
Andrey
Updated on August 12, 2022Comments
-
Andrey almost 2 years
I'm trying to get a hash of a string:
hs = hashlib.sha256(get_some_string()).hexdigest()
...but I get an error:
TypeError: Unicode-objects must be encoded before hashing