Re: Hash function

From: Date: Mon, 09 Nov 2009 11:44:53 +0000
Subject: Re: Hash function
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-299731@lists.php.net to get a copy of this message
On Mon, 2009-11-09 at 12:39 +0100, John Black wrote: > Ali Asghar Toraby Parizy wrote: > > hi friends > > I need a hash function to build a Unique serial number by mixing a request > > code and a user name > > request codes are strings like this: They are literally HEX codes of MAC mac > > addresses. > > > > "002314EFD000544AB05345300045675609782123C3254B312123D12312EE13123F123D123123E00000000E00000000E0000000E0000000E0000000E00000000E00000000" > > i want to create a function that mix together this request code with user > > name that user entered and create new serial number. > > What implications i have to satisfy to create such hash function in php? > > Thanks for any suggestion > > How about using sha1 to hash your string. If the data is unique then the > hash will be unique as well. > > $string = $request_code.$user_name; > $hash = sha1($string); > > -- > John > Jeder hat soviel Recht, wie er Macht hat. > [Spinoza] > > I'm not sure you can guarantee uniqueness, but you can say with a high degree of certainty that it's extremely unlikely to not be unique! Thanks, Ash http://www.ashleysheridan.co.uk

« previous php.general (#299731) next »