Reply to Re: Integer to code and back

Your name:

Reply:


Posted by Jerry Stuckle on 01/04/07 14:21

Tom wrote:
> "Michael Fesser" <netizen@gmx.de> wrote in message
> news:rn6op2tglcg7uda14oblqpm7ck8bkefthj@4ax.com...
>
>>.oO(Tom)
>>
>>
>>>I need to convert an integer to a unique code string consisting only of
>>>capital letters and numbers.
>>>I also need to be able to convert it back to an integer again.
>>>
>>>Example:
>>>
>>>10 => DFG56JKG4 => 10
>>
>>Just curious: Why do you need that? The integer itself is unique and
>>consists only of numbers ... so what's the purpose of the "encoding"?
>
>
> The purpose is to use it in links.
> Each code will link to a given row in a database and then show an image.
> But I don't want script kiddies to fetch all images iteratively :-)
>
> Tom
>
>

So why only numbers and capital letters? Why not lower case, also?

Or, a better question - why not just store a hash in the table itself
and forget about converting back?

Personally I think I'd just mcrypt_enc() the auto increment field with a
key and store it in the row. Then use this value in the requests.

P.S. I would use mcrypt() because it does create unique values, unlike
hashing algorithms like md5().

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация