From: "Hal E. Fulton" Date: 2001-11-13T18:19:30+09:00 Subject: [ruby-talk:24991] Mapping sequential strings to random strings: How would you do this? Hello all, Question for you. I have a problem and an idea for a solution, and I want your comments. There are (at least) two classes of answers that you might give: 1. How to properly code the solution I have in mind 2. Backing up, how to solve the problem in a completely different way. Here's the problem: Suppose I have a web directory with a fairly large number of docs in it (>1000). For convenience, I want to keep them there. However, I don't want to make ALL of them available. It's certainly possible to put an index.html in the dir, so that users can't see all the dir at once. (Just the "files du jour" that I put in the generated page.) But I don't want the names to be "guessable" -- i.e., doc001.html, doc002.html, and so on. I'm thinking of keeping some kind of mapping between the original names and "scrambled" file names. For example, the files might be named xjhfkros.html, 7glcm3lg.html, and so on. As I implied earlier, the page will be generated by code, not hardcoded. It's not necessary that the strings be "absolutely" unguessable -- just that it be highly inconvenient to retrieve an arbitrary file whose name we don't know. Constraints I'd like to see are: 1. Fixed-length scrambled strings; 2. True one-to-one mapping 3. "Reasonable" (printable) characters only 4. Non-obvious mapping Comments? Hal Fulton