On Mon, 2009-11-09 at 15:35 +0330, Ali Asghar Toraby Parizy wrote: > Ok, thanks > but how can i create serial number that nobody can guess it. for example > when i use sha1() every body can examine it too! and so they can create it > themselves! > what strategy is useful to protect license? > I think it is better to add a specific hidden string to request code, > instead of user name that is known for a probable jobber user. > what do you think about it? > > On Mon, Nov 9, 2009 at 3:09 PM, John Black <spam@xxxxxxxxxxxxxxxxxxxxxxxx>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] > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > The crypt() function in PHP offers a one-way encryption, so theoretically, it would be too difficult to work out backwards (not impossible, but would need a fair bit of computing power to figure it out!) Thanks, Ash http://www.ashleysheridan.co.uk