Skip to main content

Password manager with Fernet encryption

Project description

passwd-crypto

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

Initialization

from passwd-crypto import Passwd, generate_key_from_password

# Example usage
password = b'MyStrongPassword'
key = generate_key_from_password(password)
filename = 'passwords.txt'

# Initialize a Passwd instance
password_manager = Passwd(filename, key)

Reading Passwords

# Retrieve encrypted passwords from the file
encrypted_passwords = password_manager.getEncryptedPasswds()

# Decrypt and read stored passwords
password_entries = password_manager.read()

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)

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

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.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

passwd-crypto-0.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

passwd_crypto-0.1-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file passwd-crypto-0.1.tar.gz.

File metadata

  • Download URL: passwd-crypto-0.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.6

File hashes

Hashes for passwd-crypto-0.1.tar.gz
Algorithm Hash digest
SHA256 e4ed4dfe3f5126f91e218b25f100b7d7f49f2039d798861550fc607852651635
MD5 e9483782be97a1356637fca5406abe7c
BLAKE2b-256 0fcf8178db0b6bacc558cee0cce2ff12a2c63e39faef61cd9c7d40b74de21263

See more details on using hashes here.

File details

Details for the file passwd_crypto-0.1-py3-none-any.whl.

File metadata

  • Download URL: passwd_crypto-0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.6

File hashes

Hashes for passwd_crypto-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8114a922691505aca61e456ac7a93e3cd3d873b2a8b09b4c0669cd51bf2649be
MD5 8e50725053e61e12ab8ba26279e4d4a9
BLAKE2b-256 c7e9ea42bcfffb81b8cd297edaafef1572cd5b7e4b1a9cddca474bc328cfd0bb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page