I'm struggling a bit to generate ID of type integer
for given string
in Python.
I thought the built-it hash
function is perfect but it appears that the IDs are too long sometimes. It's a problem since I'm limited to 64bits as maximum length.
My code so far: hash(s) % 10000000000
.
The input string(s) which I can expect will be in range of 12-512 chars long.
Requirements are:
- integers only
- generated from provided string
- ideally up to 10-12 chars long (I'll have ~5 million items only)
- low probability of collision..?
I would be glad if someone can provide any tips / solutions.
I would do something like this:
The idea:
If characters
a-f
are also okay, I would dom.hexdigest()[0:12]
.