How can I generate a unique, small, random, and user-friendly key?

Here’s how I would do it.

I’d obtain a list of common English words with usage frequency and some grammatical information (like is it a noun or a verb?). I think you can look around the intertubes for some copy. Firefox is open-source and it has a spellchecker… so it must be obtainable somehow.

Then I’d run a filter on it so obscure words are removed and that words which are too long are excluded.

Then my generation algorithm would pick 2 words from the list and concatenate them and add a random 3 digits number.

I can also randomize word selection pattern between verb/nouns like

eatCake778
pickBasket524
rideFlyer113
etc..

the case needn’t be camel casing, you can randomize that as well. You can also randomize the placement of the number and the verb/noun.

And since that’s a lot of randomizing, Jeff’s The Danger of Naïveté is a must-read. Also make sure to study dictionary attacks well in advance.

And after I’d implemented it, I’d run a test to make sure that my algorithms should never collide. If the collision rate was high, then I’d play with the parameters (amount of nouns used, amount of verbs used, length of random number, total number of words, different kinds of casings etc.)

Leave a Comment