EDIT: I need to generate a string of 7 chars that is based on the id of the row.
Posted
by Totty
on Stack Overflow
See other posts from Stack Overflow
or by Totty
Published on 2010-05-12T19:31:27Z
Indexed on
2010/05/12
19:54 UTC
Read the original article
Hit count: 101
code-generation
EDIT: I need to generate a string of 7 chars that is based on the id of the row. So knowing the id of the image and a secret key, i should get the generated string.
the string must contain chars from "a" to "z" and numbers from 0 to 9.
I have a dir that contains photos like this
dir/p3/i2/s21/thumb.jpg
the generated string is p3i2s21, then is used to calculate the path of the image.
EDIT: currently im using the id of the image: id = 55 then i modify and i get path = 000000055 then path = "000/000/055" then path = "000/000/055/thumb.jpg"
ready to use!
now i want something more clever because is easy to track down all the images from a server, because ids are sequencial: 1, 2, 3, 4, 5, 6...
so i must think of creating from 55 a string that is 7 char length and will not overlap with other numbers. I can even transform the 55 to 0000055 and from this convert to a 7 char length string using a secret string. then when i got the secret string and the id i want to get back that 7 char length string.
Is this possible? i was thinking about hases but they only uses 0-9 and a-e and are more chars.. :s
© Stack Overflow or respective owner