Data::...zxcvbn(3pm)
π Data::...zxcvbn β okay bestie, sit DOWN, we're talking password strength
So Data::Password::zxcvbn is Dropbox's password estimation logic, but, like, in Perl. That's the NAME section, you're welcome. β¨
VERSION: version 1.1.3 β yes she's got a version, she's a whole entire distribution.
πΈ SYNOPSIS
use Data::Password::zxcvbn qw(password_strength);
my $strength = password_strength($my_password);
warn $strength->{warning} if $strength->{score} < 3;
Look at that. Two lines and it's done. Iconic behaviour, no notes. π«Ά
β¨ DESCRIPTION
This is a Perl port of Dropbox's password strength estimation library, "zxcvbn" <https://github.com/dropbox/zxcvbn>. Bestie it's the vibe.
The code layout has been reworked to be generally nicer β like, we use classes instead of dispatch tables, all data structures are immutable (no rogue mutation, we don't do that here π ), and we pre-compute more stuff (e.g. the dictionaries are completely pre-built, instead of being partially computed at run time. Efficiency queen.)
It's also been tested against the Python port's <https://github.com/dwolfhub/zxcvbn-python> password_expected_value.json test. And ngl? When the dictionaries contain exactly the same data (including some words that are loaded wrongly by the Javascript and Python code, due to escaping issues), our results are identical. With the dictionaries as provided in this distribution, the results (estimated number of guesses) are still within 1%. Fr fr. π
π FUNCTIONS
password_strength
my $strength = password_strength($password);
This is the main entry point for the library, and the only function you usually care about. The main character, honestly.
It analyses the given string, finding the easiest way that a password cracking algorithm would guess it, and reports on its findings. (It's basically doing a vibe check on your password's whole existence. π)
Return value
The return value is a hashref, with these keys:
guessesβ estimated guesses needed to crack passwordguesses_log10β order of magnitude ofguessescrack_times_secondsβ hashref of back-of-the-envelope crack time estimations, in seconds, based on a few scenarios:online_throttling_100_per_hourβ online attack on a service that rate-limits authentication attemptsonline_no_throttling_10_per_secondβ online attack on a service that doesn't rate-limit, or where an attacker has outsmarted rate-limiting (the audacity π€)offline_slow_hashing_1e4_per_secondβ offline attack. assumes multiple attackers, proper user-unique salting, and a slow hash function with moderate work factor, such as bcrypt, scrypt, PBKDF2.offline_fast_hashing_1e10_per_secondβ offline attack with user-unique salting but a fast hash function like SHA-1, SHA-256 or MD5. A wide range of reasonable numbers anywhere from one billion - one trillion guesses per second, depending on number of cores and machines; ball-parking at 10B/sec.
crack_times_displayβ same keys ascrack_times_seconds, but more useful for display: the values are arrayrefs["english string",$value]that can be passed to I18N libraries likeLocale::Maketextto get localised versions with proper plurals πβ¨scoreβ Integer from 0-4 (useful for implementing a strength bar):0β too guessable: risky password. (guesses < 10e3) π1β very guessable: protection from throttled online attacks. (guesses < 10e6)2β somewhat guessable: protection from un-throttled online attacks. (guesses < 10e8)3β safely un-guessable: moderate protection from offline slow-hash scenario. (guesses < 10e10)4β very un-guessable: strong protection from offline slow-hash scenario. (guesses >= 10e10) π₯
feedbackβ hashref, verbal feedback to help choose better passwords, contains useful information whenscore <= 2:warningβ a string (sometimes empty), or an arrayref[$string,@values]suitable for localisation. Explains what's wrong, e.g. 'this is a top-10 common password'.suggestionsβ a possibly-empty array of suggestions to help choose a less guessable password. e.g. 'Add another word or two'; again, elements can be strings or arrayrefs for localisation.
matchesβ the list of patterns that zxcvbn based the guess calculation on; this is rarely useful to show to users (it's giving behind-the-scenes lore that nobody asked for π)
All the objects in the returned value can be serialised to JSON, if you set convert_blessed or equivalent in your JSON library. Noted bestie, that's a real thing you might need.
Options
my $strength = password_strength($password,\%options);
You can pass in several options to customise the behaviour of this function. From most-frequently useful:
user_inputβ the most useful option: a hashref of field names and values that should be considered "obvious guesses", e.g. account name, user's real name, company name, &c. (seeData::Password::zxcvbn::Match::UserInput)max_score_for_feedbackβ the maximum"score"above which no feedback will be provided, defaults to 2; provide a higher value if you want feedback even on strong passwordsmodulesβ arrayref of module names to use instead of the built-inData::Password::zxcvbn::Match::*classes; if you want to add a module, you still have to list all the built-ins in this array;Data::Password::zxcvbn::Match::BruteForceis special, and if included here, it will be ignoredmatch_list_moduleβ module name to use instead ofData::Password::zxcvbn::MatchListto run all the computations; the module should really be a subclass of that default one, with maybe some customised messagesranked_dictionaries,l33t_tableβ dictionaries and transliteration table, seeData::Password::zxcvbn::Match::Dictionarygraphsβ adjacency graphs for keyboard-related spatial guesses, seeData::Password::zxcvbn::Match::Spatialregexesβ which regexes to use, seeData::Password::zxcvbn::Match::Regex
π¦ SEE ALSO
- the original implementation by Dropbox <https://github.com/dropbox/zxcvbn>
- the Python port <https://github.com/dwolfhub/zxcvbn-python>
π AUTHOR
Gianni Ceccarelli <gianni.ceccarelli@broadbean.com>
π COPYRIGHT AND LICENSE
This software is copyright (c) 2022 by BroadBean UK, a CareerBuilder Company.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Slay, that's the Perl license, we love legal clarity. π
ok so that's the whole thing! go forth and estimate password strength, bestie π§
Sign-off: this page was brought to you by perl v5.40.1 and dated 2025-10-17, and no those don't change, they're the footer of the page, periodt π
π¦ where this page comes from
- ubuntu resolute: libdata-password-zxcvbn-perl 1.1.3-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdata-password-zxcvbn-perl 1.1.3-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms