Forum Moderators: coopster

Message Too Old, No Replies

Encrypting and Decrypting an Interger into a 10-digit Sequence

Something like what YouTube does.

         

aeae

10:19 pm on Dec 1, 2007 (gmt 0)

10+ Year Member



I'm building a MySQL database that users of my website add content into. When information is added, a new MySQL row is added, with an unique id corrisponding with it using the Auto Incrment feature.

A dynamic page pulls information from the rows using this unique number.

What I would like to do is to "encrypt" these numbers into a sequence of something like a 10-digit sequence, something like YouTube uses.

When a user types in their special code, I can decrypt it back into the original integer and pull that content.

Something like md5($auto_id) would be great, except a 32 digit sequence is way too long, and I could only encrypt, not decrypt the intergers. I realize I could encrypt the interger and put in this encryption code into that MySQL row, but I would like to maintain the table's small size.

Any ideas?

Thanks

PHP_Chimp

10:53 pm on Dec 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you dont want an encryption, but a unique id then there is the uniqid [uk.php.net] function.

If you do want an encryption then you could look at designing your own function to encrypt the data based on the user supplies key.

aeae

11:57 pm on Dec 1, 2007 (gmt 0)

10+ Year Member



Thank you.

I'll look into developing my own function. I have an idea brewing right now.