Creating unique but readable names in C #

I am trying to write a service in which each user will be given a unique name when he first uses this service. I want to generate this name, and not try to configure it. In addition, I want the name to be somewhat readable and memorable, rather than resembling a GUID or timestamp. Essentially, I want this to be something like an Xbox gamertag.

I know that there will never be more than 1000 users, so maintaining uniqueness will not be a problem (another reason I can afford to avoid the GUID)

I’m thinking about taking from the dictionary some adjectives, nouns, etc. and generate random but unique combinations of them.

Any suggestions?

+4
source share
3 answers

You can use the corpus of n-grams of English (say, three letter sequences) and use them to generate words that look like English but are really completely gibberish. Such data are essentially random, but have softness for the nature of human language and memory.

This is similar to what I'm talking about , except that it combines probabilistic words into sentences probabilistically. I thought more about this, putting together sequences of letters in imaginary words.

EDIT actually on this page discusses what I'm talking about.

+3
source

This is just an example of code that is fully suited to your problem. If this does not solve the problem, try clarifying your question. Continue to the next method with an instance of the System.Random class and a list of words (your dictionary).

 static string GetGuid(Random random, IList<string> words) { const int minGuidSize = 10; const int maxGuidSize = 15; var builder = new StringBuilder(); while (builder.Length < minGuidSize) builder.Append(words[random.Next(words.Count)]); return builder.ToString(0, Math.Min(builder.Length, maxGuidSize)); } 
+1
source

You can use this list of 10,000 random names: http://www.opensourcecf.com/1/2009/05/10000-Random-Names-Database.cfm

or use this site to create a random list of the first name: http://www.fakenamegenerator.com/order.php

Safe way. keep a list of the remaining unused names.

A simple way (also very scalable), but unsafe. Rely on the unlikely fact that 2 users accidentally receive the same identifier.

I would try to get 3 or 4 lists from about a thousand modalities, and then randomly select one value in each list. This would make about 10E12 possibilities, which are enough to avoid a collision for 1000 users.

JohnLampMartin2212

+1
source

All Articles