From: Stefan Schmiedl Date: 2001-11-13T21:21:57+09:00 Subject: [ruby-talk:25005] Re: Mapping sequential strings to random strings: How would you do this? Niklas Frykholm (2001-11-13 20:16): > But you can eliminate collisions entirely by prepending a document > identifier (such as 001) to each name. Then the hash part will just > make the name hard to guess. With four characters in that part, it will > take on average 32000 attempts to guess it. Perhaps that is OK. > > name = id + MD5.md5(id + secret).hexdigest[0,4] + '.html' > and to simplify things further, if you can use a document id, you can use Ruby's builtin numbering scheme starting from a randomly chosen four letter word .-) irb(main):001:0> "dumb".succ "dumc" irb(main):002:0> "dumb".succ.succ "dumd" Of course, you'd lose the fancy MD5, and be more predictable, but it's easy to implement and not quite easy to guess, especially if you order the files according to some non-intuitive criterium. s. -- Stefan Schmiedl EDV-Beratung, Programmierung, Schulung Loreleystr. 5, 94315 Straubing, Germany Tel. (0 94 21) 74 01 06 Public Key: http://xss.de/stefan.public shhhh ... I can't hear my code!