jackr1909 Posted June 27, 2011 Share Posted June 27, 2011 Hi all, i was wondering if there was any way if i could encode a long peice of information into a shorter peice using a php function. I have investigated md5 checksums, but the results is too long for my use. The output would probably need to be unique. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/240501-short-encoding/ Share on other sites More sharing options...
TeNDoLLA Posted June 27, 2011 Share Posted June 27, 2011 Could you give an example of input and desired output ? Quote Link to comment https://forums.phpfreaks.com/topic/240501-short-encoding/#findComment-1235289 Share on other sites More sharing options...
jackr1909 Posted June 27, 2011 Author Share Posted June 27, 2011 Input = is a URL ranging from 10 to 1000 characters output = preferably 4 to 10 Symbols or any nature example INPUT = http://www.google.com/#hl=en&xhr=t&q=facebook&cp=2&qe=ZmE&qesig=izpuHiAoRAp1c-r2Cuqj1Q&pkc=AFgZ2tnuhygagbRbQrJht9pQsq3RzKOPuizwSVxdLbVPfeC1iOJ5Szud6Caw0D8Re44_nXZezfsKE96ETr7vIaNSEU7lJVEM_g&pf=p&sclient=psy&site=&source=hp&aq=0&aqi=&aql=&oq=fa&pbx=1&bav=on.2,or.r_gc.r_pw.&fp=cfd4938828d57dcb&biw=1024&bih=602 output = Yna23@( Quote Link to comment https://forums.phpfreaks.com/topic/240501-short-encoding/#findComment-1235320 Share on other sites More sharing options...
TeNDoLLA Posted June 27, 2011 Share Posted June 27, 2011 Really haven't done this ever before. You might try search words like "php shorten url" in google to get some tutorials/scripts. Also an idea popped up my mind to make a script on your site to create and store short urls in db. Create some identefier to the script that would indicate its shortened url and when user enters this particular url, you would fetch from db the original url and redirect the user. I dunno how bad or good this would be though. Maybe there is someone else who can give you more useful advice. Quote Link to comment https://forums.phpfreaks.com/topic/240501-short-encoding/#findComment-1235497 Share on other sites More sharing options...
jackr1909 Posted June 28, 2011 Author Share Posted June 28, 2011 sure, thanks What i have ended up doing is a 6 key random generator. And then queried a DB to check if it already exists. The chances of a duplicate are: 51 520 374 361 to one so i don't really have to worry about loading time thanks Quote Link to comment https://forums.phpfreaks.com/topic/240501-short-encoding/#findComment-1235735 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.