A Python CLI application for generating RSA public and private key pairs using the cryptography library
Features • Installation • Usage • Configuration • Development • License
Features
Encryption Helper is a robust Python package designed to simplify the process of creating RSA key pairs. It leverages the cryptography library to offer:
- Generation of 2048-bit RSA key pairs
- Automatic saving of keys in PEM format
- Logging of key generation for debugging purposes
- Simple CLI interface for ease of use
Installation
This package requires Python 3.8 or later and uses cryptography for cryptographic operations.
Using Poetry (recommended)
Ensure you have Poetry installed, then follow these steps:
# Clone the repository git clone https://github.com/hsbc/encryption-helper-python.git cd encryption-helper-python # Install dependencies (including cryptography) poetry install
Using pip
If you prefer to use pip:
# Clone the repository git clone https://github.com/hsbc/encryption-helper-python.git cd encryption-helper-python # Create a virtual environment (optional but recommended) python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` # Install the package and its dependencies (including cryptography) pip install .
Usage
With Poetry
To generate an RSA key pair using Poetry:
poetry run encryption-helper
With standard Python
If you installed the package using pip:
# If you're using a virtual environment, make sure it's activated
encryption-helperOr run the module directly:
python -m encryption_helper
These commands will:
- Use cryptography to generate a 2048-bit RSA key pair
- Save the private key to
keys/pem/private-key.pem - Save the public key to
keys/pem/public-key.pem - Display both keys in the console
- Log the key generation process
Configuration
The key generation process uses cryptography with the following specifications:
- Standard: PKCS#1
- Type: RSA
- Size: 2048 bits
To modify these settings, you'll need to edit the generate_rsa_key() function in encryption_helper/main.py. Refer to the cryptography documentation for more advanced configurations.
Development
With Poetry
To set up the development environment using Poetry:
# Create a virtual environment and install dependencies poetry install # Activate the virtual environment poetry shell # Run tests pytest tests/ # Generate documentation pydoc -w encryption_helper
With standard Python
If you're not using Poetry:
# Create a virtual environment python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` # Install development dependencies pip install .[dev] # Run tests pytest tests/ # Generate documentation pydoc -w encryption_helper
License
This project is licensed under the MIT License. See the LICENSE file for details.
