I am looking to create a small encrypted string, like the referral strings used by Twitpic or bit.ly, for a website I am working on for referral purposes. Any of the built-in functions like MD5 and mcrypt each make strings that are too long for my purposes.
Is there an easy way to create a string like this? Thanks.
From the question, I’m guessing that you just want to have a short string of text/numbers that uniquely refers to a username, an image, an URL or something similar.
A solution would be just to generate a random string and map that to the user/image/URL in your database. Here’s the random string function we use. You can adjust
$charsdepending on your application. It can generate a short 5-letter string like twitpic if necessary.