Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suggestion on encrypting data for unique IDs

Status
Not open for further replies.

kasuals

Programmer
Apr 28, 2002
100
US
I'm creating unique IDs within a table for members. For my purposes it has to be unique and at least 10 chars long.

Is this pretty much a given that the ID will come out unique?

$mix = date("BisZU");
$mix = $mix."".$_POST[username]."";
$memberID = base64_encode(pack("H*",md5($mix)));

Or should I handle it some other way?

- "Delightfully confusing..." raves The New York Times

-kas
 
Yes, it will not be unique, but no more so than concatenating the date with the userid, so there's no reason to use it. The base64 encoding algorithm is designed to be nothing more than a way of encoding 8-bit data for transmission on a 7-bit stream.

Try an MD5 hash instead -- what you want to do is what it is designed for.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
or you can always use the password function..

password(); much like md5();

but from my understanding you can not undo the encryption, qould be interested in knowing what can someone do in the event that you want to retreive your password and it is displayed in encrypted form.. is there a way to turn in back to human reading form to email back to a user in the event that they forget they password?.

Max

Nothing is hard when you realy want to learn it.

Max
 
To my knowledge it is irreversible - and that's good so. It is intended to provide one-way encryption, and that's just what it does.
If someone forgets their password, forget it! A new one serves better and is the safe thing to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top