def string2numeric_hash(text): import hashlib return int(hashlib.md5(text).hexdigest()[:8], 16) # test >>print string2numeric_hash('this is a nice string') 1962341389
References
1. http://stackoverflow.com/questions/2511058/persistent-hashing-of-strings-in-python