16bit hash
Robin Becker
robin at reportlab.com
Thu Jun 28 09:35:37 EDT 2007
Thomas Jollans wrote:
> Robin Becker wrote:
.......
>> I'm not sure my postscript is really good enough to do the latter so I
>> hoped to pursue a python based approach which has a low probability of
>> busting. Originally I thought the range was a 16bit number which is why
>> I started with 16bit hashes.
>
>
> For identifying something, I suggest you use a hash function like sha1
> truncating it to as much as you can use, similarly to what Jon Ribbens
> suggested.
that is in fact what I'm doing; my function looks like this
4000000+(reduce(operator.xor,struct.unpack('i'*4,md5.md5(s).digest()))&0x3ffff)
whether it's any better than using the lowest bits I have no real idea. I
suppose (sha being flavour of the month) I should really use
4000000+(reduce(operator.xor,struct.unpack('i'*5,sha.sha(s).digest()))&0x3ffff)
--
Robin Becker
More information about the Python-list
mailing list