Skip to content

Instantly share code, notes, and snippets.

@killertilapia
Created September 25, 2019 05:58
Show Gist options
  • Save killertilapia/45bbac1722a071fa3ed604ccdbfc1586 to your computer and use it in GitHub Desktop.
Save killertilapia/45bbac1722a071fa3ed604ccdbfc1586 to your computer and use it in GitHub Desktop.
Simple cheap string hasher in Python
import hashlib
def compute_cheap_hash(txt, length=8):
hash = hashlib.md5()
hash.update(txt.encode('utf8'))
return hash.hexdigest()[:length]
'''
Example:
$ compute_cheap_hash("AB-RTCMC-32.768KHZ-IBO5-S3")
ab6600a4
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment