Skip to main content

Componentes adicionais de aplicativos clientes Confy

Project description


Confy Addons

Componentes adicionais de aplicativos clientes Confy.

Test Coverage PyPI - Version PyPI - Python Version GitHub License Visitors


A Python package that provides symmetric and asymmetric encryption functions for client applications of the Confy encrypted communication system, as well as prefixes that identify messages and encryption keys sent by applications during the handshake process. The package also includes functions to encode and decode the public RSA key to base64 for sending over the network.

Learn more about the project at github.com/confy-security

Made with dedication by students from Brazil 🇧🇷.

⚡ Using

Install the package

Install the package with the package manager used in your project.

For example, with pip:

pip install confy-addons

Or with Poetry:

poetry add confy-addons

Usage example

Import the necessary classes

from confy_addons import (
    AESEncryption,
    RSAEncryption,
    RSAPublicEncryption,
    deserialize_public_key,
)

This imports all the encryption classes and utilities needed for RSA and AES operations.

Generate an RSA key pair

rsa_handler = RSAEncryption()
private_key = rsa_handler.private_key

Creates a new RSA encryption handler that automatically generates a 4096-bit key pair. The private key is extracted for later decryption operations.

Serialize and share the public key

pub_key_b64 = rsa_handler.base64_public_key
deserialized_pub_key = deserialize_public_key(pub_key_b64)

The public key is serialized to a base64-encoded PEM format, which can be safely transmitted over text-based protocols. The deserialized version is reconstructed from the encoded string for encryption operations.

Create an RSA public encryption handler

rsa_public_handler = RSAPublicEncryption(key=deserialized_pub_key)

Initializes an RSA encryption handler using only the public key. This handler can encrypt data that only the holder of the private key can decrypt.

Generate and encrypt an AES key

aes_handler = AESEncryption()
encrypted_aes_key = rsa_public_handler.encrypt(aes_handler.key)

Generates a random 256-bit AES key and encrypts it using RSA public key encryption. This allows secure transmission of the symmetric key to the recipient.

Decrypt the AES key with the RSA private key

decrypted_aes_key = rsa_handler.decrypt(encrypted_aes_key)
aes_handler_decrypted = AESEncryption(key=decrypted_aes_key)

Decrypts the AES key using the RSA private key. A new AES handler is created with the decrypted key for symmetric encryption and decryption operations.

Encrypt and decrypt messages with AES

secret_message = "Secret message"
encrypted_message = aes_handler.encrypt(secret_message)
decrypted_message = aes_handler_decrypted.decrypt(encrypted_message)
print(decrypted_message)

Encrypts a plaintext message using AES-256 in CFB mode and then decrypts it back to verify the process works correctly. The output will display the original secret message.

Dependencies

Confy Addons relies only on cryptography.

Contributing

If you would like to contribute to the project, see more information at CONTRIBUTING.md.

License

Confy Addons is open source software licensed under the GPL-3.0 license.

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

confy_addons-1.1.0.tar.gz (34.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

confy_addons-1.1.0-py3-none-any.whl (35.8 kB view details)

Uploaded Python 3

File details

Details for the file confy_addons-1.1.0.tar.gz.

File metadata

  • Download URL: confy_addons-1.1.0.tar.gz
  • Upload date:
  • Size: 34.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for confy_addons-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2236a5df3ebd3f99b33276495324921de140ae83a9cafd71700d1698d0372ae7
MD5 7e067664a19502e6edf057d020d83c43
BLAKE2b-256 03ed5e592c4e409032d9fb2d59e25ed95c4784b1592e259f9f6feb60c8d1372d

See more details on using hashes here.

Provenance

The following attestation bundles were made for confy_addons-1.1.0.tar.gz:

Publisher: publish.yml on confy-security/confy-addons

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file confy_addons-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: confy_addons-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 35.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for confy_addons-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 58efb6f7f23851d18aa22e31edcc2122f95aaf231c79e1531d30c12b4a741caa
MD5 1146637ae07790844dec98968a33deb7
BLAKE2b-256 72018eec5905ad5d20f4835cf876d9128275a4352002f92290fb412bd6948839

See more details on using hashes here.

Provenance

The following attestation bundles were made for confy_addons-1.1.0-py3-none-any.whl:

Publisher: publish.yml on confy-security/confy-addons

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page