Safe¶
Is your password safe? Safe will check the password strength for you.
How it works¶
Safe will check if the password has a simple pattern, for instance:
- password is in the order on your QWERT keyboards.
- password is simple alphabet step by step, such as: abcd, 1357
Safe will check if the password is a common used password. Many thanks to Mark Burnett for the great work on 10000 Top Passwords.
Safe will check if the password has mixed number, alphabet, marks.
Installation¶
Install Safe with pip:
$ pip install Safe
If pip is not available, try easy_install:
$ easy_install Safe
Usage¶
It’s very simple to check the strength of a password:
>>> import safe
>>> safe.safety(1)
terrible
>>> safe.safety('password')
simpile
>>> safe.safety('is.safe')
medium
>>> safe.safety('x*V-92Ba')
strong
>>> strength = safe.safety('x*V-92Ba')
>>> bool(strength)
True
>>> repr(strength)
'strong'
>>> str(strength)
'password is perfect'
>>> strength.valid
True
>>> strength.strength
'strong'
>>> strength.message
'good password'
Environ Variables¶
- PYTHON_SAFE_WORDS_CACHE: cache words in this file, default is a tempfile
- PYTHON_SAFE_WORDS_FILE: words vocabulary file, default is the 10k top passwords
Other Implementations¶
- JavaScript: lepture/safe.js
Developer Guide¶
Here is the API reference for safe.
-
safe.
safety
(raw, length=4, freq=0)¶ Check the safety level of the password.
Parameters: - raw – raw text password.
- length – minimal length of the password.
-
class
safe.
Strength
(valid, strength, message)¶ Measure the strength of a password.
Here are some common usages of strength:
>>> strength = Strength(True, 'strong', 'password is perfect') >>> bool(strength) True >>> repr(strength) 'strong' >>> str(strength) 'password is perfect'
Parameters: - valid – if the password is valid to use
- strength – the strength level of the password
- message – a message related to the password
-
safe.
is_asdf
(raw)¶ If the password is in the order on keyboard.
-
safe.
is_by_step
(raw)¶ If the password is alphabet step by step.
-
safe.
is_common_password
(raw, freq=0)¶ If the password is common used.
10k top passwords: https://xato.net/passwords/more-top-worst-passwords/