views:

908

answers:

5

Would like to create a strong password in C++. Any suggestions?

  • I assume it should use alpha (upper and lower), numeric, special characters.

  • It would be good to be able to specify a minimum length.

  • It would be great to avoid characters that are hard to visually distinguish like "O" and "O"

  • It would be great to void all characters same, dictionary words, reversed words, names.

Any other tips? Where could I find code like this?

+1  A: 

You can try a TRNG device plus some well known algorithms, the best way lead with it ;)

daniel
+3  A: 

There's a few ways. The easy isn't necessarily the best

Create a string representing all the characters you want to define (meaning, no O's or 0s's, whatever), then fill a random-length string with random characters from that set.

The next step is to keep generating until you pass all assertions. That is, check for dictionary words, reverse names, etc.

There will be times where generation takes longer than expected, but should still be faster than you can notice.

+2  A: 

You could use OpenSSL's random generator, then base64 encode it. (Won't get you all sorts of random characters, but will get you many.). It also won't do the similar character password bit though, sadly. My favorite generator is here, and it provides the features you're talking about. (Web-only, sadly)

Rizwan Kassim
+2  A: 
Josh Kelley
I like the story about how the German Enigma crypto machine was broken in part by noticing that it never encrypted a plaintext character to the same ciphertext character, it *always* chose a different letter.
Greg Hewgill
+1  A: 

There are documented requirements that several sources use, such as FIPS 181.

I would suggest looking at the documentation for the popular Automated Password Generator utility. Looking at the options that it provides and the capabilities could go a long way for you.

Also, look at checking your generated passwords so that they meet the threshold for your application.

Wikipedia also lists some existing designs and standards.

Kris Kumler