Skip to main content

A simple tools to hybrid encryption and decryption

Project description

Installation

pip install -U xrypt-xethhung12

Usage

import json
from xrypt_xethhung12.xrypt.xrypt import read_public_key_from_pem, read_private_key_from_pem, DeEnCryptor


def load_file(file_path: str) -> dict:
    with open(file_path, 'r') as f:
        data = json.load(f)
    return data


if __name__ == '__main__':
    base_path = "./"
    s_pub = read_public_key_from_pem(base_path + "s_pub.key")
    s_pri = read_private_key_from_pem(base_path + "s_pri.key")
    r_pub = read_public_key_from_pem(base_path + "r_pub.key")
    r_pri = read_private_key_from_pem(base_path + "r_pri.key")
    d = load_file(base_path + "encrypted-data")

    deen = DeEnCryptor(s_pub, s_pri)
    container = deen.encryptToContainer(r_pub, "helloworld")
    containerStr = deen.encryptToJsonContainer(r_pub, "helloworld")
    print(containerStr)

    deen = DeEnCryptor(r_pub, r_pri)
    print(deen.decryptContainer(s_pub, container))

Scripts

Generate rsa key pair

pri={pri}
pub={pub}
openssl genrsa -out $pri 4096
openssl rsa -in $pri -outform PEM -pubout -out $pub

Build

rm -fr dist
python3 -m build

Build and Deploy

rm -fr dist
python3 -m build
twine upload dist/* -u __token__ -p $pwd

Update version dev

python3 -m xh_py_project_versioning --patch

Update version

python3 -m xh_py_project_versioning --patch -d

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

xrypt_xethhung12-0.0.7.tar.gz (3.0 kB view hashes)

Uploaded Source

Built Distribution

xrypt_xethhung12-0.0.7-py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 3

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