This directory contains Python examples using the libzupt library through pybind11 bindings.
- Python 3.8 or higher
- pybind11
- CMake 3.15 or higher
- A C++17 compatible compiler
cd examples_python
./build.shexport PYTHONPATH="build:$PYTHONPATH"
python3 example_basic.pycd build
python3 -m pip install .- example_basic.py - Basic encryption/decryption with memory data
- example_file.py - Encrypting and decrypting files
- example_keygen.py - Key generation and management
- example_secure_buffer.py - Using SecureBuffer for zeroizing sensitive data
- example_random.py - Generating random bytes and computing hashes
generate_keypair()- Generate a new hybrid key pairload_keypair(filename)- Load a key pair from fileload_public_key(filename)- Load a public key from fileexport_public_key(privfile, pubfile)- Export public key from private key filesave_keypair(keypair, filename)- Save a key pair to file
encrypt(data)- Encrypt bytes in memoryencrypt_secure(buffer)- Encrypt SecureBufferencrypt_file(filename)- Encrypt a fileHEADER_SIZE- Size of encryption header
decrypt(ciphertext, enc_header)- Decrypt bytesdecrypt_secure(ciphertext, enc_header)- Decrypt to SecureBufferdecrypt_file(filename, enc_header)- Decrypt a file
SecureBuffer(data)- Create from bytesSecureBuffer(size)- Create empty bufferzeroize()- Securely wipe memoryto_bytes()- Convert to bytesto_string()- Convert to string
random_bytes(size)- Generate cryptographically secure random bytessha256(data)- Compute SHA-256 hashsha3_512(data)- Compute SHA3-512 hashsecure_wipe(data, size)- Securely wipe memory
SPDX-License-Identifier: MIT