Skip to main content

The CryptographyManager is a tool designed to securely encrypt and decrypt messages and data. It uses modern encryption techniques to protect confidential information.

Project description

risclog.cryptography

CI Status https://img.shields.io/pypi/v/risclog.cryptography.svg

The CryptographyManager is a tool designed to securely encrypt and decrypt messages and data. It uses modern encryption techniques to protect confidential information.

Requirements

To use the CryptographyManager, ensure you have the following:
  • Python 3.9 or later

  • The cryptography library, which can be installed using pip install cryptography.

Installation

Download the code for the CryptographyManager into your Python environment or add it directly to your Python project. Make sure that all dependencies are installed.

Example for installing the cryptography library:

$ pip install risclog.cryptography

Usage

Initialization

To use the CryptographyManager, you will need a password and a “salt” (a random string to enhance security).

from risclog.cryptography import CryptographyManager

password = "my_secure_password"
salt = "my_secure_salt"

# Initialize the CryptographyManager
crypto_manager = CryptographyManager(password=password, salt=salt)

Encryption

To encrypt a message, use the encrypt method. This is particularly useful for protecting sensitive data like passwords or personal information.

  1. Input the text you want to encrypt.

  2. Call the encrypt method.

message = "This is a secret message"
encrypted_message = crypto_manager.encrypt(message)

print(f"Encrypted message: {encrypted_message}")

Decryption

To decrypt an encrypted message, use the decrypt method:

  1. Call the decrypt method with the encrypted message.

  2. The original message will be restored.

decrypted_message = crypto_manager.decrypt(encrypted_message)

print(f"Decrypted message: {decrypted_message}")

Troubleshooting

Wrong password or salt: If you try to decrypt a message with a different password or salt than what was used for encryption, you will get an error. Make sure to use the same password and salt.

Invalid messages: Encryption requires valid strings or bytes. Ensure the text is correctly formatted.

Event-loop issues (with async): If you’re using the encryption in an asynchronous environment (e.g., web applications), the manager will automatically detect if an event loop is running and adjust accordingly.

Security Tips

Password security: Choose a strong and secure password. A weak password can compromise the security of the encryption.

Use salt: Whenever possible, use a salt to make brute-force attacks more difficult. The salt should be unique for each user or message.

Key storage: Safeguard the password and salt securely. If they are lost, encrypted data cannot be recovered.

Tests

Run tests:

$ ./pytest

Credits

This package was created with Cookiecutter and the risclog-solution/risclog-cookiecutter-pypackage project template.

This package uses AppEnv for running tests inside this package.

Change log for risclog.cryptography

1.1 (2024-09-13)

  • added default salt. Can be used with a single instance

1.0 (2024-09-11)

  • initial release

Project details


Download files

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

Source Distribution

risclog.cryptography-1.1.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

risclog.cryptography-1.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file risclog.cryptography-1.1.tar.gz.

File metadata

  • Download URL: risclog.cryptography-1.1.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for risclog.cryptography-1.1.tar.gz
Algorithm Hash digest
SHA256 181225794dfdbb14395a565cb9d6c6a296faa8c479441ee747661246c749eb61
MD5 d2ef4615061159c44f01e16cd4b0b843
BLAKE2b-256 751d692d0b5ea93625891f63bce4b65bc1d281010f281154828a44bb2eb18120

See more details on using hashes here.

File details

Details for the file risclog.cryptography-1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for risclog.cryptography-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c7907dc11ee5b6976dfa10708ad3429fa28ea53df3c1c6fb57d3dc82f0e00e31
MD5 77f6e85abfb49fe3cac4485010ff6675
BLAKE2b-256 767983a6d9e30460cff7bdcc5f8c7498a3781a2a58ca9708bfefcbff40345dcf

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