Convert 32-char md5 string to integer
问题 What's the most efficient way to convert an md5 hash to a unique integer to perform a modulus operation? 回答1: Since the solution language was not specified, Python is used for this example. import os import hashlib array = os.urandom(1 << 20) md5 = hashlib.md5() md5.update(array) digest = md5.hexdigest() number = int(digest, 16) print(number % YOUR_NUMBER) 回答2: You haven't said what platform you're running on, or what the format of this hash is. Presumably it's hex, so you've got 16 bytes of