Created
September 25, 2019 05:58
-
-
Save killertilapia/45bbac1722a071fa3ed604ccdbfc1586 to your computer and use it in GitHub Desktop.
Simple cheap string hasher in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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