A realistic password strength estimator.
.................................................bbb.................... .zzzzzzzzzz..xxx....xxx....cccccccc..vvv....vvv..bbb.........nnnnnnn.... .....zzzz......xxxxxx....cccc........vvv....vvv..bbbbbbbb....nnn...nnn.. ...zzzz........xxxxxx....cccc..........vvvvvv....bbb....bb...nnn...nnn.. .zzzzzzzzzz..xxx....xxx....cccccccc......vv......bbbbbbbb....nnn...nnn.. ........................................................................
An obj-c port of zxcvbn, a password strength estimation library, designed for iOS.
DBZxcvbnattempts to give sound password advice through pattern matching and conservative entropy calculations. It finds 10k common passwords, common American names and surnames, common English words, and common patterns like dates, repeats (aaa), sequences (abcd), and QWERTY patterns.
Check out the original JavaScript (well, CoffeeScript) or the Python port.
For full motivation, see zxcvbn: realistic password strength estimation.
Coming soon.
The easiest way to use
DBZxcvbnis by displaying a
DBPasswordStrengthMeterin your form. Set up your
UITextFieldDelegateand add a
DBPasswordStrengthMeter.
See the example here: DBCreateAccountViewController.m
As the user types, you can call
scorePassword:like so: ``` objc - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSString *password = [textField.text stringByReplacingCharactersInRange:range withString:string];
[self.passwordStrengthMeterView scorePassword:password];return YES;
} ```
Here is what
DBPasswordStrengthMeterlooks like in a form:
To use
DBZxcvbnwithout the
DBPasswordStrengthMeterview simply import
DBZxcvbn.h, create a new instance of
DBZxcvbn, then call
passwordStrength:userInputs:.
#importDBZxcvbn *zxcvbn = [[DBZxcvbn alloc] init]; DBResult *result = [zxcvbn passwordStrength:password userInputs:userInputs];
The DBResult includes a few properties:
result.entropy // bitsresult.crackTime // estimation of actual crack time, in seconds.
result.crackTimeDisplay // same crack time, as a friendlier string: // "instant", "6 minutes", "centuries", etc.
result.score // [0,1,2,3,4] if crack time is less than // [102, 104, 106, 108, Infinity]. // (useful for implementing a strength bar.)
result.matchSequence // the list of patterns that zxcvbn based the // entropy calculation on.
result.calcTime // how long it took to calculate an answer, // in milliseconds. usually only a few ms.
The optional
userInputsargument is an array of strings that
DBZxcvbnwill add to its internal dictionary. This can be whatever list of strings you like, but is meant for user inputs from other fields of the form, like name and email. That way a password that includes the user's personal info can be heavily penalized. This list is also good for site-specific vocabulary.
Thanks to Dropbox for supporting independent projects and open source software.
A huge thanks to Dan Wheeler for the original CoffeeScript implementation. Thanks to Ryan Pearl for his Python port. I've enjoyed copying your code :)
Echoing the acknowledgments from earlier libraries...
Many thanks to Mark Burnett for releasing his 10k top passwords list:
http://xato.net/passwords/more-top-worst-passwords
and for his 2006 book, "Perfect Passwords: Selection, Protection, Authentication"
Huge thanks to Wiktionary contributors for building a frequency list of English as used in television and movies: http://en.wiktionary.org/wiki/Wiktionary:Frequency_lists
Last but not least, big thanks to xkcd :) https://xkcd.com/936/