Re: [BangPypers] Hash function that returns unsigned integer

2012-08-31 Thread Ramchandra Apte
We could use pow(character,somenumber,mod) to do it. It is secure but it may not be fast enough. ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers

Re: [BangPypers] Hash function that returns unsigned integer

2012-08-31 Thread Philippe May
The probability of getting non unique values is logically multiplied by 2 using the modulo method. If you don't mind dealing with long integers, you can simply add the absolute value of the minimum integer: hash(value) + sys.maxint + 1. In any case, i think it's better to use sys.maxint, instead

Re: [BangPypers] Hash function that returns unsigned integer

2012-08-31 Thread Yoganand Anandaraju
Will that be unique(near unique)? Want to make sure hashing someother string will not produce the same hash value. - Original Message - From: Ramchandra Apte Sent: 08/31/12 01:29 PM To: Bangalore Python Users Group - India Subject: Re: [BangPypers] Hash function that returns unsigned int

Re: [BangPypers] Hash function that returns unsigned integer

2012-08-31 Thread Ramchandra Apte
Just modulo the hash function `hash_value % (2**32)` On 31 August 2012 12:46, Yoganand Anandaraju wrote: > Is anyone aware of any non-cryptographic hash function whose value is only > postive integer. Pythons inbuilt hash function is a signed integer. > > > Regards, > Yoganand > ___

[BangPypers] Hash function that returns unsigned integer

2012-08-31 Thread Yoganand Anandaraju
Is anyone aware of any non-cryptographic hash function whose value is only postive integer. Pythons inbuilt hash function is a signed integer. Regards, Yoganand ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo