Skip to main content

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 via pip. "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 by chaes.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:

image

Metadata

Release files for Chaeslib 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Chaeslib 1.0.1
File Size Uploaded
Chaeslib-1.0.1.tar.gz 18.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Chaeslib 1.0.1
File Interpreter ABI Platform
Chaeslib-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 34.6 kB

Release files / Chaeslib-1.0.1.tar.gz

Download URL Chaeslib-1.0.1.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3c345a337b166681b061ecd3dc1789bb2a53308eaeff3c3df67efa4214918c03
BLAKE2b-256 checksum
How to use checksums
1275a39f04f614124330f6f0fd47658fab3c64fbf2f087ba03401e48468f9c36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / Chaeslib-1.0.1-py3-none-any.whl

Download URL Chaeslib-1.0.1-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f29cba35e83daf80958de616c6ccea84dd5def072c34fc81844767513c71b98b
BLAKE2b-256 checksum
How to use checksums
8b5655eb5e0207809e4641ad4dfc4fddab292d542be6aaf2f583334693eda7f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page