KeyCipher
keycipher is a Python utility package for encrypting and decrypting text using AES-GCM with a secret key. It provides simple functions to handle secure encryption and decryption.
Installation
To install the package, use pip:
pip install keycipher
Usage
Here’s a brief guide on how to use the keycipher package.
Importing the Package
from keycipher import encrypt_data, decrypt_data
Encrypting Data
To encrypt a piece of text, use the encrypt_data function. You need to provide the plaintext and a key string.
from keycipher import encrypt_data
key_string = 'your-secret-key' # Replace with your key
plain_text = 'This is a secret message' # Replace with your text
encrypted_data = encrypt_data(plain_text, key_string)
print('Encrypted Data:', encrypted_data)
Decrypting Data
To decrypt data, use the decrypt_data function. You need to provide the encrypted data and the same key string used for encryption.
from keycipher import decrypt_data
encrypted_data = {
'iv': '...your IV...',
'cipherText': '...your cipherText...',
'tag': '...your tag...'
} # Replace with your generated encryption object
key_string = 'your-secret-key' # Replace with your key
decrypted_text = decrypt_data(encrypted_data, key_string)
print('Decrypted Text:', decrypted_text)
API
encrypt_data(plain_text, key_string)
Encrypts the given plaintext using the provided key string.
-
Arguments:
plain_text(str): The text to be encrypted.key_string(str): The key used for encryption.
-
Returns: A dictionary containing
iv,cipherText, andtag.
decrypt_data(encrypted_data, key_string)
Decrypts the given encrypted data using the provided key string.
-
Arguments:
encrypted_data(dict): The encrypted data object, which includesiv,cipherText, andtag.key_string(str): The key used for decryption.
-
Returns: The decrypted text.
Example
Here’s a complete example showing both encryption and decryption:
from keycipher import encrypt_data, decrypt_data
# Encryption
key_string = 'your-secret-key'
plain_text = 'This is a secret message'
encrypted_data = encrypt_data(plain_text, key_string)
print('Encrypted Data:', encrypted_data)
# Decryption
decrypted_text = decrypt_data(encrypted_data, key_string)
print('Decrypted Text:', decrypted_text)
About the Author
keycipher is created by Parth Dudhatra (imParth), a passionate software engineer, developer advocate, and content creator known for his contributions to the tech community. He is passionate about frontend development, Python programming, open-source software, and sharing knowledge with others.
Parth is active on various social media platforms, where he shares insights, tutorials, and tips related to programming, web development, and software engineering. Parth's dedication to sharing his expertise and fostering a supportive environment for developers has earned him recognition and respect within the tech community. Connect with Parth Dudhatra on social media:
If you have any questions, feedback, or suggestions, feel free to reach out to me on any platform!
License
This project is licensed under the ISC License.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.
Issues
If you encounter any issues, please report them on the issues page.
Metadata
Release files for keycipher 1.0.0
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 |
|---|---|---|---|---|
| keycipher-1.0.0.tar.gz | 3.8 kB | Without provenance | Details for keycipher-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| keycipher-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for keycipher-1.0.0-py3-none-any.whl |
Total release size: 7.6 kB
Release files / keycipher-1.0.0.tar.gz
| Download URL | keycipher-1.0.0.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f0afe4480cae982515c021a861486756dba489c44e14a8c6389b6c237fe19692
|
|
BLAKE2b-256 checksum How to use checksums |
ef1963ef9de1df928737e7b529a118231d72733c6ce506d2c41f116df3e1f947
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.1
|
Release files / keycipher-1.0.0-py3-none-any.whl
| Download URL | keycipher-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e24d6fd241dee88158c1fcfc4f958d9692318badf0ee38c7c75c3f64d6d04cf5
|
|
BLAKE2b-256 checksum How to use checksums |
54406c238b54c640e1cb6f13222d10907aa4e78df100701e91f9339422871ade
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.1
|
Security for keycipher 1.0.0
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.