Passwordler Tutorial
Welcome to the Passwordler package documentation! This package offers a suite of functions designed to enhance your online password security. Here, we illustrate the usage of these functions with real-life examples, featuring Bob, a baseball fan who learned the hard way about the importance of strong passwords.
Bob’s Journey
For the past 10 years, Bob has been using the password ‘baseball’ for all his online accounts. While this made them easy to remember, it also made them easy to hack. Unfortunately for Bob, some not-so-flattering photos of his trip to Cancun were sent to all of his Facebook friends. Due to this incident, Bob has decided to up his password security using our Passwordler functions.
Password Strength
The function password_strength allows users to test the strength-rating of their passwords, giving ratings of ‘Weak’, ‘Good’, and ‘Strong’. It takes one argument, password, the password as a string.
Testing It Out
Bob begins by testing the strength of his previously used password, ‘baseball’.
from passwordler.password_strength import password_strength
password_strength('baseball')
'Your password is: Weak'
As we can see, his password was weak! No wonder they were able to hack his account. Next he tries a few more variations to see if he can create something stronger.
Note: A password is classified as weak if it is found in our list of common passwords, or does not meet the criteria for a ‘Good’ password
password_strength('Baseball4life')
'Your password is: Good'
Almost there, but he really wants a ‘Strong’ password.
Note: A good password contains at least 8 characters and at least two capital letters, numbers or special characters in total.
password_strength('Baseball4life!')
'Your password is: Strong'
Finally! Something Bob can work with, he’s found a password he likes that is also strong. But then Bob reads about our password generator and decides to give that a try instead.
Note: A strong password has 12 or more characters and at least one capital letter, one number and one special character each.
Generate Password
The generate_password function allows users to create a secure, customized password. It has three optional arguments. The first argument, length, corresponds to the desired length of the password given as an integer. Its minimum and default length is 12 and it’s maximum is 100. The second argument is include_symbols while the third argument is include_numbers. They both take a boolean value, indicating whether special characters and numbers should be included in the generated password.
Password Generator Defaults
To start out, Bob creates a password with the default settings.
from passwordler.generate_password import generate_password
generate_password()
'st<LUJ0rq/ww'
Note: This returns a password of length 12, with at least one uppercase letter, number and symbol.
Going for Length
Intrigued, Bob decides to generate a much longer password, setting the length to its maximum: 100 characters.
generate_password(length=100)
'N{KDo2?Fh6eZmy-~yozf^L7Y\'=:hK@zkWMb)T#RI/4\'Q2:&~"Kz8$bv}R$L|r%RD%a;g8U$GCX0tu?OhVZS~rkza]tMk?;(cN[!8'
Simplifying It
While this was a fun, it is simply too long to be useful for Bob. Next, he experiments with the include_symbols and include_numbers arguments. He sets both to false, overriding the default settings.
Note: This gives him a password with only letters: removing symbols and numbers.
generate_password(include_symbols=False, include_numbers=False)
'KvsJoAlXAMaB'
Ultimately, Bob decides to stick to his ‘Baseball4life!’ password from earlier, but wants to try out our encryption function to further increase his security.
Encrypt a Password
The encrypt_password function encrypts a password using a simple substitution cipher, by substituting each character with a corresponding character from a shuffled set. It uses the same set of characters as the decryption function, so they can work in tandem. Its first argument, password, requires a string input, while the second optional argument, random_seed, accepts an integer value.
Encryption Defaults
Bob realizes that he needs to store his new password on his computer. However, he is worried that he might be hacked again so he decides to use the encrypt_password function. He tries the default setting first.
from passwordler.encrypt_password import encrypt_password
# Encrypt a password with a default seed
encrypted_password = encrypt_password("Baseball4life!")
print(encrypted_password) # Prints the encrypted password
l.õ!p.gg3gíI!{
Note: The random seed argument controls the shuffled character mapping, its default is 123.
Customizing the Seed
Bob realises that the only way to keep his password safe is to customize the seed, so he chooses a random number, avoiding his date of birth or anything that others could easily guess. This means that he needs to store the seed and the encrypted password in two different places. Bob encrypts the password using the seed 42428.
# Encrypt a password with a specific seed
encrypted_password = encrypt_password("Baseball4life!", 42428)
print(encrypted_password) # Prints the encrypted password using the specified seed
ñ1ã4ÿ1``o`Wf4a
Decrypt a Password
The decrypt_password function decrypts a password that has previously been encrypted with the encrypt_password function. It requires the same seed that was used in the encrypt_password. It takes two arguments, the first encrypted_password is the encrypted password passed in as a string. The random_seed argument is the seed that was used to encrypt the password, passed in as an integer value.
Decryption Defaults
The next time Bob tries to log in to Facebook, he can’t remember his password. Bob knows where he saved his encrypted password on his computer, but he cannot find the seed, so he tries to decrypt his encrypted password with the default settings.
from passwordler.decrypt_password import decrypt_password
decrypt_password(encrypted_password)
'2E@ãnEyyóyâqãö'
Note: if no random seed argument is given, the default of 123 will be used.
Using the Encryption Seed
Ah, that does not look like his original password! Bob has to search through his notebook to find the seed he used for the encryption. Fortunately, he finds it and tries to decrypt his password again.
decrypt_password(encrypted_password, 42428)
'Baseball4life!'
Boo-yah! That is the original password! With the help of Passwordler, Bob is now protected against any embarrassing future mishaps.
Final Remarks
We hope you found these examples informative and learned through Bob’s password mistakes. If anything remains unclear, we suggest reviewing the function documentation or creating an issue in our repository and we will get back to you.