order independent hash?

Neal Becker ndbecker2 at gmail.com
Thu Dec 1 08:55:38 EST 2011


Gelonida N wrote:

> On 11/30/2011 01:32 PM, Neal Becker wrote:
>> I like to hash a list of words (actually, the command line args of my
>> program) in such a way that different words will create different hash, but
>> not sensitive
>> to the order of the words.  Any ideas?
>> 
> Do youmean hash like digest like md5sum / sha1 ?
> 
> 
> You should sort the words alphabetically, concatenate them with a space
> or any character, that will NEVER be part of a word and calulate the hash.
> 
> If words can exist multiple times, then youhad tu uniqufy them (u using
> a python dict / set) first.

Yes that sounds just like what I wanted - thanks!




More information about the Python-list mailing list