Use SHA1 to hash larger strings so that they can be used as keys in the database.
Trying to create a UUID-sized string from the original string, which is random enough and large enough to protect against collisions, but much smaller than the original string.
Do not use this for safety.
Example:
def _get_database_key(very_long_key):
return hashlib.sha1(very_long_key).digest()
Is SHA1 a good algorithm for this purpose? Or is there something even more suitable?
source
share