convert numbers into string

I have a photo album web application...There is a photo_id parameter referencing photos like photo_id=23 (23 is an integer type value as u see)

users can easily try new photos by changing the parameter on the link. like photo_id=24 , 25 ,26 to n as you see...

I want youtube type references like photo_id=zAprzX2O6Zs and users cant guess the values easily...

I want to convert my integer values to a string and on theuser side.and on the servlet side i need to reverse the function and get the integer values.

so i need a fast and simple algorithm..Do you know any? or can you show me a good way?

thank you

[643 byte] By [netsonicca] at [2007-11-26 21:35:29]
# 1
Many possibilites. An easy one is Base64 encoding/decoding. It can be easily broken by users, but only if they know it is being done, or have volumes of examples and are willing to try and "crack" it.
masijade.a at 2007-7-10 3:15:59 > top of Java-index,Java Essentials,Java Programming...
# 2
i need a very fast two way algorithm...so doesnt matter to be cracked easily...i can always have chance to change the algorithmthanks for this and any other alternatives
netsonicca at 2007-7-10 3:15:59 > top of Java-index,Java Essentials,Java Programming...
# 3
some simple ideas...use Random numbersmd5 hash
robtafta at 2007-7-10 3:15:59 > top of Java-index,Java Essentials,Java Programming...
# 4
md5 can not be reversed...can it be?
netsonicca at 2007-7-10 3:15:59 > top of Java-index,Java Essentials,Java Programming...
# 5

> md5 can not be reversed...can it be?

It is computationally prohibitive to reverse an MD5 hash.

I would use probably a ten-or-so-digit random number and convert that to Base64 (keeping it URL-compatible), if you really need that step for the geek factor. Base64 is easily encoded and decoded:

http://forum.java.sun.com/thread.jspa?forumID=31&threadID=477461

kevjavaa at 2007-7-10 3:15:59 > top of Java-index,Java Essentials,Java Programming...
# 6

why does the photo ID have to be sequencial? If you want it to be fast, store the photo ID's they way you want them and just use that instead of 1,2,3...etc. If you use MD5s as the photo ID's, there is no need to convert anything, although that does leave the question, what will be passed through md5? Random characters is probably better.

robtafta at 2007-7-10 3:15:59 > top of Java-index,Java Essentials,Java Programming...
# 7

changing the database index type will be more harder...and searching database with hex strings will need more power i think...searching with primary key integer value will be more faster in my opinion...

so i am searching for on the fly encrypt and decryption...it s a personal choice and can be discussed...

netsonicca at 2007-7-10 3:16:00 > top of Java-index,Java Essentials,Java Programming...