Is it possible to generate a secure permutation F over 32-bit integers even if F(0) … F(n) is public knowledge?

I'm currently interested in the problem of generating random-looking URLs from sequential database IDs, like how they do it in link shorteners. One way to do this is to encrypt the sequential database ids using a 32 bit block cypher and base62 encode the result so it can be written to the URL.

For example:

foo.com/1       foo.com/2        -- Original sequential IDs
foo.com/142365  foo.com/226340   -- Encrypt IDs using a permutation function
foo.com/b2D     foo.com/wse      -- Encode in base62 format - looks random + compact.


Now here is the catch: Whenever we encrypt the a new database ID and publish the URL, that plaintext-ciphertext pair become public knowledge. Is it possible to create an encryption system that makes it hard to guess what will be the next URL we will generate? That is, can we make it so the attacker can't guess the value of $F(1000000)$ even if he knows the values of $F(n)$ for $n \leq 999999$?

Some things that I think are important to note:

• The cypher must have a 32 bit block size. Otherwise, the resulting URLs get too long.
• The secret key is allowed to be any size.
• Each number is only be encrypted once and all the messages I encrypt are 32 bits in length. (None of the stream-cypher stuff applies)

My actual use case – and most people's, to be honest – won't really need that kind of security. A bijective mapping from sequential IDs to URLs that looks scrambled at first glance is good enough. However, I am now curious if that unpredictability requirement is possible to achieve. In my searches, I found a lot of people saying that 32 bit blocks are too small due to the birthday problem but I am not sure that caveat applies here. On the other hand, none of the 32-bit block cyphers I found say anything about their resistance to known cyphertext attacks…

• If you use a 36-bit permutation you can encode to 6 6-bit characters, which will fill the character domain much better, seeing as a 32-bit permutation will still require the same. A 42-bit one will allow a 7-bit internal structure and encode to 7 characters. – Richie Frame Sep 5 '14 at 8:35
• To satisfy my curiosity I created the 42-bit cipher since I had some of the building blocks already created. It will encode to 7 chars just like an Imgur URL. How secure I do not know, but it is similar to the HIGHT cipher in structure. – Richie Frame Sep 6 '14 at 11:17
• The downside of 6-bit characters is that you need to use 2 symbols because three are only 62 alphanumerics. I think I'm going to use 40-bit permutations with 5-bit characters. – hugomg Sep 10 '14 at 3:52
• Just increment the counter till you get something without the non alphanumeric characters. You still get 3.5 trillion out of the 4.4 trillion to use, vs the 1.1 trillion for 40-bit, while saving 1 byte in the URL. 40-bit does allow an 8-bit internal structure however, which allows better s-boxes – Richie Frame Sep 10 '14 at 4:01
• Im growing fond of the 32 bit version. Lowercase letters don't scream as much as uppercase ones :) – hugomg Sep 10 '14 at 4:51