Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A while back I created a licensing system for my companies new product, as well as all products after this one. As with a lot of licensing systems mine generates codes: 25 character product and registration codes, as well as 16 character module unlocking codes.

My question is, since some parts of these generated codes are random should I apply a language filter to it to avoid any embarrassing language being given to the end users?

I chose to as it was not difficult at all.

But has anyone else ever came across something like this? Any viewpoints as to if it is worth the effort?

share|improve this question
I think this will turn into the The Automated Curse Generator pretty quickly. – Joachim Sauer Oct 18 '11 at 9:28
up vote 9 down vote accepted

It depends (as always).

Assuming that your string can produce runs of 4 or more alphabetical characters then such words will turn up from time to time.


  1. Will your users notice?
  2. Will they get upset enough to contact the company?
  3. Will this cause financial problems - loss of sales etc.?

If the answers are yes then you should "sanitise" your strings.

However - if you decide to do this you should really check for "embarrassing language" in other languages - French, German, Polish, Swahili.... Where do you draw the line?

It might be simpler to either not bother or change your licensing system so that it only uses hexadecimal codes (say) or generates the code in blocks of 4 characters split by dashes with a rule that each block should contain a number.

share|improve this answer
I think the simple rule that avoids the problem altogether is much more useful. If your alphabetical characters are always in the ASCII range, you can simplify your sanitation to only words that fit in that range (which can rule out some European embarrassing words). Of course, if you ensure that there is no more than two letters consecutively you can't even form three letter embarrassing words--like the euphemism for what you sit on. – Berin Loritsch Feb 10 '11 at 13:18
@Berin - I also think changing the generation code to avoid the problem is better. Perhaps I should have emphasised it more. – ChrisF Feb 10 '11 at 13:25
@Berin: A-five-five :-) – Dean Harding Feb 10 '11 at 13:29
Due to the nature of the code generation it had already limited it down to 3 letter words and at most in the rare case 4 letter words. So the filter function was relatively simple but next time I get to work on it I think I will try to eliminate the need for the filter all together. Thank you! – Tim Feb 10 '11 at 13:33
+1 - would just like to add a point for filtering: if you're going to be emailing these codes to customers, you don't want their spam filtering or IT people to be diverting the email. Some corporate networks I've used are quite ridiculously restrictive on such things. Just thought it worth mentioning. – TZHX Feb 10 '11 at 14:43

Interpreting your question in the worst case scenario: let's assume the 25- and 16-character strings are simply alphabet letters. That's 25^26 and 16^26 combinations of your randomly generated strings! The first naughty words that come to mind are around the 4-letter mark, so, in my opinion the two reasons not to bother about sanitising the codes are:

  1. 4^26 will contain a tiny amount of naughty words, and
  2. Since the character strings are quite lengthy, I'd also think the remaining characters will naturally do a brilliant job of obfuscating anything randomly generated.
share|improve this answer
Which is my first point - "will your users notice?". I also think that despite being mathematically rare they will turn up sooner rather than later;) – ChrisF Feb 10 '11 at 13:27
You'd be surprised at how well the human brain will pick out the naughty words. (BTW, the shortest naughty word I know is only three characters and rhymes with a type of fish). If there is one thing we folks are good at, it is recognizing patterns. The more socially sensitive a pattern is, the quicker it is noticed. – Berin Loritsch Feb 10 '11 at 13:28
@Berin Loritsch: If the user is having to 'pick' out a naughty word, I'd say that is more of a reflection on the user. Given the length of the randomly generated strings, there's no way anyone would think it's intentionally offensive. Nevertheless, my answer would be different if the product is something like teaching children their first (English) words... – Jonathan Khoo Feb 10 '11 at 13:36
I think you missed the point of my comment. It's an involuntary reaction that the brain has, something that says "ooh, that's bad" because the person has been scolded for using such language before. Because it causes social problems and we are by nature social beings, we are more sensitive to certain words than others. I'm not saying the user is actively searching for the word (although some juveniles might). (cont.) – Berin Loritsch Feb 10 '11 at 13:46
If the user reflected on the occasion for any length of time, they'll rightly deduce that they randomly got the short end of the stick. However, that won't stop some people from complaining loudly, or if it got out on the news, causing damage to the reputation of the company. Of course, if the software caters to people who relish naughty words, that might increase the reputation of the company with their users--but that's a niche market. – Berin Loritsch Feb 10 '11 at 13:49

Our application currently supports 15 languages.

Filtering all those languages is pretty hard. Plus adding a new language would mean reviewing the filter.

share|improve this answer

Why do humans let themselves be offended by a word (of their own making)? Is this typical behaviour on this planet? Is this a requirement to be considered adult? Is this a requirement to be considered sane? Is this a requirement to be considered responsible?

It's just a word. Man up!

share|improve this answer
George Carlin and I agree with you. But my management has a different opinion. lol – Tim Feb 14 '11 at 15:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.