Introduction
This code implements a simple encryption/decryption mechanism to secure messages using the cryptography library in Python.
Features
- PBKDF2 key derivation is used to derive a secret key from a given password and salt
- The message is encrypted using the Fernet module from the cryptography library
- The encryption process uses a random 16-byte salt, a user-specified number of iterations for the key derivation function, and the derived key to encrypt the message.
- The encrypted message is returned as a base64 encoded string
- The decryption process takes the encrypted message, password and decodes the encrypted message to retrieve the salt, iteration count and encrypted token
- The secret key is derived again using the password and salt, and the encrypted message is decrypted using Fernet
- The decrypted message is returned as a string
Requirements
- Python 3.x
- cryptography library
Usage
The code provides two main functions:
message_encrypt(message, password, iterations=100_000) and message_decrypt(token, password).
message_encrypt takes in the following arguments:
message: The message to be encrypted, as a string
password: The password used to derive the secret key, as a string
iterations: The number of iterations for the key derivation function. The default value is 100,000.
message_decrypt takes in the following arguments:
token: The encrypted message, as a string
password: The password used to derive the secret key and decrypt the message, as a string
The code returns the encrypted message or the decrypted message as a string.
Limitations
The encryption mechanism is only secure if the password is strong and kept confidential.
Metadata
Release files for darkencryption 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| darkencryption-0.0.2.tar.gz | 14.9 kB | Without provenance | Details for darkencryption-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| darkencryption-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for darkencryption-0.0.2-py3-none-any.whl |
Total release size: 30.2 kB
Release files / darkencryption-0.0.2.tar.gz
| Download URL | darkencryption-0.0.2.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
098a7c41d0ff2e7f3920c2503cd79ed3ad48f0d2fe7abd33eb2beb51fa4a751a
|
|
BLAKE2b-256 checksum How to use checksums |
ffaef31f799af11e18a90243561ee18d1b89eedda273ab4b4473acceaacce37d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / darkencryption-0.0.2-py3-none-any.whl
| Download URL | darkencryption-0.0.2-py3-none-any.whl |
|---|---|
| Size | 15.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4988034b2e9bcae74cd80675dac62eb365b24078223a88b9e357ab7079fb8739
|
|
BLAKE2b-256 checksum How to use checksums |
fbb11b1e3082a6bd6b2b025b9fccd1883a4546b5845bf267eff5501642f1b310
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Security for darkencryption 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.