https://github.com/confy-security/confy-addons
Implementation of symmetric and asymmetric encryption with AES and RSA algorithms for client applications of the Confy communication system
https://github.com/confy-security/confy-addons
aes base64 confy cryptography decryption encryption privacy rsa security
Last synced: 5 months ago
JSON representation
Implementation of symmetric and asymmetric encryption with AES and RSA algorithms for client applications of the Confy communication system
- Host: GitHub
- URL: https://github.com/confy-security/confy-addons
- Owner: confy-security
- License: gpl-3.0
- Created: 2025-08-08T16:19:52.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2026-01-24T11:18:38.000Z (5 months ago)
- Last Synced: 2026-01-24T22:09:53.726Z (5 months ago)
- Topics: aes, base64, confy, cryptography, decryption, encryption, privacy, rsa, security
- Language: Python
- Homepage: https://pypi.org/project/confy-addons
- Size: 247 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Citation: CITATION.cff
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
Confy Addons
Implementation of symmetric and asymmetric encryption with AES and RSA algorithms for client applications of the Confy communication system.
[](https://github.com/confy-security/confy-addons/actions/workflows/test.yml)
[](https://coverage-badge.samuelcolvin.workers.dev/redirect/confy-security/confy-addons)
[](https://pypi.org/project/confy-addons/)
[](https://pypi.org/project/confy-addons/)
[](/LICENSE)
[](https://github.com/confy-security/confy-addons)
---
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](https://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:
```shell
pip install confy-addons
```
Or with Poetry:
```shell
poetry add confy-addons
```
### Usage example
#### Import the necessary classes
```python
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
```python
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
```python
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
```python
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
```python
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
```python
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
```python
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`](https://cryptography.io/).
## Contributing
If you would like to contribute to the project, see more information at [CONTRIBUTING.md](CONTRIBUTING.md).
## License
Confy Addons is open source software licensed under the [GPL-3.0](https://github.com/confy-security/confy-addons/blob/main/LICENSE) license.