A minimalistic and simple AES256-GCM+ChaCha20_Poly1305 library. For encrypting data using both 'AES256-GCM' & 'ChaCha20_Poly1305'.
Project description
Chaeslib
A pypi package that uses AES-GCM and ChaCha20_Poly1305 encryption to encrypt and decrypt your data.
About
This library was made possible beause of my project called Chaes. It uses the same functinality here to encrypt and decrypt messages and files. I wanted that project to be more shareable so thus this lib/package was born. (I am still kinda new to making packages).
Installation
virtualenv chaENV
source chaENV/bin/activate
pip install Chaeslib
If you don't have
virtualenv
you can install it viapip
. "pip install virtualenv
".
Example | Documentation
This very basic example is what I do to make things work and showcase how to use things. (Copy and pasting this code will give you something that works for encrypting messages.) If you replace the way to get a message with opening a file and getting bytes, then it can work for files as well. (It is up to you to optimize for large files.)
from Chaeslib import Chaes
import base64
if __name__ == '__main__':
# flag 1: decrypt | flag 2: encrypt
flag = 2
if flag == 1:
chaes = Chaes()
dKey = input("Encryption Key: ")
dMessage = input("Encrypted Message: ")
enc_message = chaes.hex_to_base64(dMessage)
#Decode message and get salt and key after splitting on ":" to make a list.
json_input = base64.b64decode(enc_message)
key_and_salt = dKey.split(":")
salt_1 = key_and_salt[1]
key_0 = key_and_salt[0]
salt = base64.b64decode(salt_1)
key = base64.b64decode(key_0)
cha_aes_crypt = chaes.decrypt(key, json_input, salt)
chaes.clear()
input(f'Here is your encrypted message: {cha_aes_crypt.decode()}\n\nPress "enter" to contine...')
chaes.clear()
if flag == 2:
chaes = Chaes()
message = input("Message to encrypt: ").encode()
key_data = input("Data for key gen: ").encode()
chaes.clear()
eKey = chaes.keygen(key_data) #Returns bytes and will return "None" if what's provided is less than 100 characters.
if not eKey:
exit()
save_me = base64.b64encode(eKey)
bSalt = base64.b64encode(chaes.salt)
master_key = f"{save_me.decode()}:{bSalt.decode()}"
input(f'Save this key so you can decrypt later: {master_key}\n\nPress "enter" to contine...')
chaes.clear()
enc_msg = chaes.encrypt(message, eKey)
print(enc_msg)
- chaes.clear()
Clears your terminal
- chaes.encrypt(message, key)
Encrypts bytes/data.
-
message
is the bytes/data you want to encrypt. -
key
is the key that was generated bychaes.keygen()
- chaes.decrypt(key, json_input, salt)
Decrypts your encrypted data/message.
-
key
is the key that was used to encrypt your data. -
json_input
is the base64 decoed json data that has your encrypted data. -
salt
is the other half of the "key" that was used to encrypt your data.
- chaes.keygen(key_data)
Generates a "key" to be used to encrypt your data. (uses argon2id)
-
key_data
is just a bunch of keyboard mashing and spamming to get a bunch of garble to make a key. (You could use Genter to make a key if you'd like.)
Support | Buy me a coffee <3
Donate to me here:
- Don't have Cashapp? Sign Up
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file Chaeslib-1.0.1.tar.gz
.
File metadata
- Download URL: Chaeslib-1.0.1.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c345a337b166681b061ecd3dc1789bb2a53308eaeff3c3df67efa4214918c03 |
|
MD5 | 3f44c7bd3a9b809104076e599d9144b2 |
|
BLAKE2b-256 | 1275a39f04f614124330f6f0fd47658fab3c64fbf2f087ba03401e48468f9c36 |
File details
Details for the file Chaeslib-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: Chaeslib-1.0.1-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f29cba35e83daf80958de616c6ccea84dd5def072c34fc81844767513c71b98b |
|
MD5 | ae5f4fc081efecb1cd90c7b188d899e5 |
|
BLAKE2b-256 | 8b5655eb5e0207809e4641ad4dfc4fddab292d542be6aaf2f583334693eda7f3 |