passwordcrypto
This Python module provides a simple password manager for securely storing and retrieving encrypted password entries. The passwords are encrypted using the Fernet symmetric encryption scheme. The module includes functionality to derive a Fernet key from a password, initialize a password manager instance, retrieve encrypted passwords, decrypt and read stored passwords, encrypt text, and write new password entries to a file.
Usage
Installation
Execute the following command: pip install passwordcrypto
For windows users it's recommended to execute pythonX.YY -m pip install passwordcrypto
Change X.YY to the python version you use
Initialization
import passwordcrypto
# Example usage
password = bytes(input("Write your password: "))
filename = 'passwords.txt'
# Initialize a Passwd instance
password_manager = passwordcrypto.Passwd(filename, password)
Reading Passwords
password_entries = password_manager.read()
""" Outputs a list of passwords which themselves are a list of [App, Email, Password]
Example: [
['testApp', 'testEmail', 'testPassword'],
['testApp2','testEmail2','testPassword2'],
]
"""
Writing Passwords
# Write a new password entry to the file
app_name = 'MyApp'
email_address = 'user@example.com'
user_password = 'SecurePassword123'
password_manager.write(app_name, email_address, user_password)
Example
import passwordcrypto
inputKey = bytes(input("Insert your password: ").encode())
passwodManager = passwordcrypto.Passwd("example.txt", inputKey)
while True:
option = input("\nWhat do you want to do? (1: Read 2: Write): ")
match option:
case "1":
print("\nAPP, EMAIL, PASSWORD")
passwordList = passwodManager.read()
for line in passwordList:
print(", ".join(line))
case "2":
app = input("Insert app name: ")
email = input("Insert email/username: ")
password = input("Insert password: ")
passwodManager.write(app,email,password)
case _:
exit()
API Reference
generate_key_from_password(password: bytes) -> Fernet
Generates a Fernet key derived from the provided password.
class Passwd(filename: str, key: bytes) -> None
Initialize a Passwd instance.
filename (str): The name of the file to store encrypted passwords.key (bytes): The Fernet key used for encryption and decryption.
getEncryptedPasswds() -> list[bytes]
Retrieve encrypted passwords from the file.
read() -> list[list[str]]
Decrypt and read stored passwords from the file. Returns a list of decrypted password entries, where each entry is a list with the format [App, Email, Password].
encrypt(text: str) -> bytes
Encrypt the given text using the Fernet key.
text (str): The text to be encrypted.
write(app: str, email: str, password: str) -> None
Encrypt and write a new password entry to the file.
app (str): The application or service name.email (str): The associated email address.password (str): The password for the application or service.
Security Note
The password used to create the instances of Passwd should not be stored anywhere, instead inputted by the user.
Adjust the number of iterations in the key derivation process (iterations parameter in generate_key_from_password) based on your security requirements. Higher iterations increase security but also result in longer key derivation times.
Release files for passwordcrypto 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| passwordcrypto-1.0.6.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| passwordcrypto-1.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.5 kB
Release files / passwordcrypto-1.0.6.tar.gz
| Download URL | passwordcrypto-1.0.6.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9fedb529be295fbd0a5b9aa345807efad8c4877ea3d615fbc5dae4adc496e35a
|
|
BLAKE2b-256 checksum How to use checksums |
3f0cce53e7f22d9798e27b22120a67c60759cca07839caf2a9169fa41a15a6e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.6
|
Release files / passwordcrypto-1.0.6-py3-none-any.whl
| Download URL | passwordcrypto-1.0.6-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48d0bbdce7c24d46ce816f0e3b8fb50cd4b500d97cd58ef16fda7e7c99892982
|
|
BLAKE2b-256 checksum How to use checksums |
70c77cda80daf325cdb6de60913fb9fd57fe9d1193f8a19b91af034fc6f983ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.6
|