Generating server-side passwords is horrible as well since you're counting on the user to write it down and/or let the browser's password manager save it. What if the user wants to log in with a different machine/browser?
I think the best solution is to, first, forbid passwords under 10 characters. 8 is still relatively secure, but not really, 10 at least gives you a fighting chance. Second, run your own dictionary attack (you can load /usr/share/dict/words into a hashtable and check for membership in sub-second times..in fact, here:
import sys
f = open('/usr/share/dict/words')
words = {}
for line in f:
words[line.replace('\n','')] = None
if sys.argv[1] in words:
print 'You fail'
) and alert the user if their password sucks and to pick a new one. (You might want to check for membership of their password with an 's' or a '1' or something added on as well.) You might also want to do some sort of complexity analysis as well that requires e.g. at least one uppercase, one lowercase, one number.The infrastructure problem is places like Banks saying "Enter a password between 6 and 12 characters and only use alphanumeric characters!"
with open('/usr/share/dict/words') as wordlist:
words = set(line[:-1] for line in wordlist)
Or, for one time check you can stop reading on match: import sys
lookup = '%s\n' % sys.argv[1]
with open('/usr/share/dict/words') as wordlist:
[ sys.stdout.write('Dictionary password: %s' % lookup) or sys.exit(1) for line in wordlist if line == lookup ]
As for the objective, this checks only exact dictionary matches. In real world, you'd use cracklib to check any dictionary based or weak passwords rather than reinvent the wheel. See http://gdub.wordpress.com/2006/08/26/using-cracklib-to-requi... import sys
lookup = '%s\n' % sys.argv[1]
with open('/usr/share/dict/words') as wordlist:
for line in wordlist:
if line == lookup:
sys.stdout.write('Dictionary password: %s' % lookup)
sys.exit(1) import pickle
# initialize:
wordset = frozenset(line.lower().rstrip() for line in open('/usr/share/dict/words'))
pickle.dump(wordset, open('/tmp/wordset.pkl', 'wb', -1))
# when you want to use it:
wordset = pickle.load(open('/tmp/wordset.pkl', 'rb'))
'bear' in wordset # == True >python wordlist.py -w wordlist -p wordlist.pkl
>python wordlist.py -T wordlist wordlist.pkl 10 3
2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
words(wordfile): 142.50 best msec/loop
words_slower(wordfile): 161.00 best msec/loop
words_normalized(wordfile): 295.84 best msec/loop
words_pickled(pickled): 2943.66 best msec/loop
The winner is: with open(wordfile) as wordlist:
return frozenset(wordlist.read().split('\n'))
Source: https://gist.github.com/1059725Wordlist: http://www.freebsd.org/cgi/cvsweb.cgi/src/share/dict/web2?re...
Do you have different results?
That unfortunately puts a lot of confidence in the security of the sites that you give your password to. Your super safe password is not that safe if a site stores it as plaintext or MD5 and it gets hacked.
Otherwise I agree with your comment.
https://github.com/search?q=password+strength https://sun.athnic.net/password-test.html http://www.geekwisdom.com/dyn/passwdmeter http://cafewebmaster.com/check-password-safety-javascript-wh...
I used a method a few years ago to generate passwords for users on an intranet. They were free to replace them, but a poll showed that most users went with the suggested password. I focused on generating passwords that users could pronounce (and therefore remember), like gekava86, lofesu75, 23wopeni, etc.
At the time, I didn't use BCrypt so they were a bit weak (though certainly stronger than whatever the users' regular password was). If you use BCrypt, you don't have to worry as much about the password being "strong", the focus comes back to it being unique.
So the problem is that passwords tend not to be random. This greatly decreases the problem-space. But b/scrypt solves the problem of length, within reason.
This is why MD5 is not a good password-based key derivation function. :-)
Using punctuation does not make a password "more random", it only makes the random choice set slightly larger. Bumping the length is much more significant than bumping the set as it's exponential.
The debate is whether it's easier for a user to both pick and remember a "random-enough" - i.e not easily bruteforce-able, regardless of hashing technology - [A-Za-z]{10} password or a [A-Za-z0-9!@#$%^&()_-+=;':",.<>/?\|[\]{}]{8} password.
For the record, Google's 2-factor auth generated app-specific passwords are [a-z]{16}, which gives 1E22, or 230 billion years with bcrypt at 0.3s.
For instance, a plain alphanum password of length 9 is stronger than a password of length 8 that allows for special characters. (because 62^9 > 94^8)
In other words, adding one character to your password is as good as choosing from a bigger character set.
Okay, beginning at length 10, you'd need to add two characters, but that's really all you need to do up to length 20. (which is an insane length for a random password anyway)
Assuming the attacker brute-forces all 3 word combinations, maybe. But "fluffy is puffy" is a valid English sentence and language is a rather poor source of entropy.
Depending on the attack scenarios, that may not actually be more risky than allowing users to choose their own password..
I'd say that the best compromise of these approaches would be to encourage the use of password safe programs which at least store the password list in an encrypted format on local machines (of course this still relies on the user choosing a strong password for the password safe..)
That isn't the problem. Reuse is. And the best way around that is to not let the user select the password, just generate it server side. Technically this is easier to get right than some complex password generation scheme and the end result is properly better too.