Skip to main content

A simple tools to hybrid encryption and decryption

Project description

Installation

pip install -U xrypt-xethhung12

Usage

from xrypt_xethhung12.rsa_encryption import gen_key_pair, read_public_key_from_pem_str, read_private_key_from_pem_str
from xrypt_xethhung12.rsa_format import pub_key_to_pem, pri_key_to_pem
from xrypt_xethhung12.xrypt.xrypt import DeEnCryptor, Signer, Verifier

if __name__ == '__main__':
    # Generate key pair
    s_pub, s_pri = gen_key_pair()
    r_pub, r_pri = gen_key_pair()

    # encrypt and decrypt
    data_encrypted = DeEnCryptor(s_pub, s_pri).encryptToContainer(r_pub, "helloworld")
    data = DeEnCryptor(r_pub, r_pri).decryptContainer(s_pub, data_encrypted)
    print(data)

    # sign and verify
    signed_data = Signer(s_pri).sign("helloworld")
    print(Verifier(s_pub).verify(signed_data))

    # To pem format string
    print(pub_key_to_pem(s_pub))
    print(pri_key_to_pem(s_pri))

    reloaded_s_pub_key = read_public_key_from_pem_str(pub_key_to_pem(s_pub))
    reloaded_s_pri_key = read_private_key_from_pem_str(pri_key_to_pem(s_pri))
    reloaded_r_pub_key = read_public_key_from_pem_str(pub_key_to_pem(r_pub))
    reloaded_r_pri_key = read_private_key_from_pem_str(pri_key_to_pem(r_pri))

    # encrypt and decrypt - again
    data_encrypted = DeEnCryptor(reloaded_s_pub_key, reloaded_s_pri_key).encryptToContainer(reloaded_r_pub_key, "helloworld")
    data = DeEnCryptor(reloaded_r_pub_key, reloaded_r_pri_key).decryptContainer(reloaded_s_pub_key, data_encrypted)
    print(data)

    # sign and verify - again
    signed_data = Signer(reloaded_s_pri_key).sign("helloworld")
    print(Verifier(reloaded_s_pub_key).verify(signed_data))

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.10.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

xrypt_xethhung12-0.0.10-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file xrypt-xethhung12-0.0.10.tar.gz.

File metadata

  • Download URL: xrypt-xethhung12-0.0.10.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for xrypt-xethhung12-0.0.10.tar.gz
Algorithm Hash digest
SHA256 b9cdf2d091f9aceebf3a5918bdfc19aa6ea566d3a320cbb4c27d1be8d04f63a8
MD5 7b6eb5aaab2222037ae425dff0c0bbc2
BLAKE2b-256 322797650b579154e234c7968feb66b9e0d61863d8bd991e221f54a3549ca976

See more details on using hashes here.

File details

Details for the file xrypt_xethhung12-0.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for xrypt_xethhung12-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 eed0ee736e3bf7c6a2fa90291bc88d1a60e0d3f1b75955ff435c0656de0eb10d
MD5 1b06011542e603f450a1691e1f787257
BLAKE2b-256 50686e6eaf193c9693fc5a8a87fe3800d8286f6d317ae166af21a54330fc2a3a

See more details on using hashes here.

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