Skip to main content

A fast, lightweight, pure-Python RSA implementation

Project description

SimpleRSA

RSA impementation for casual tasks

Features

  • Zero Dependencies: Uses only Python standard libraries. No C-compilers or external packages required.
  • Automatic Chunking: Encrypt messages of any length. The library automatically splits massive texts into block sizes appropriate for your key.
  • Safe Encoding: Outputs ciphertexts as JSON-bundled Base64 strings, preventing encoding errors during copy-pasting.

Installation

Install via pip: If you published this to PyPI:

pip install simple-rsa

Install locally from source:

git clone https://github.com/yourusername/simple-rsa.git
cd simple-rsa
pip install .

Quickstart

1.Generating Keys

Generate a public/private keypair. The standard is 2048 bits.

from simple_rsa import generate_keys

# Generate keys (returns PublicKey and PrivateKey objects)
public_key, private_key = generate_keys(key_size_bits=2048)

2. Encrypting & Decrypting

You can encrypt strings of any size. The library handles the math and chunking behind the scenes.

from simple_rsa import encrypt, decrypt

secret_message = "Hello! This is a highly classified message."

# Encrypt (Outputs a Base64 string)
ciphertext = encrypt(secret_message, public_key)
print(f"Encrypted: {ciphertext}")

# Decrypt
decrypted_message = decrypt(ciphertext, private_key)
print(f"Decrypted: {decrypted_message}")

3. Saving & Loading Keys

Easily export your keys to disk as JSON files to use later.

from simple_rsa import PublicKey, PrivateKey

# Save to disk
public_key.export_key("public_key.json")
private_key.export_key("private_key.json")

# Load from disk
loaded_pub = PublicKey.import_key("public_key.json")
loaded_priv = PrivateKey.import_key("private_key.json")

Security Disclaimer

This library implements Unpadded Textbook RSA with basic block chunking. It is highly effective for:

  • Educational purposes and learning cryptography.
  • Capture The Flag (CTF) challenges.
  • Internal lightweight tooling or hobby projects.

However, it is NOT recommended for mission-critical, state-actor-level production environments. Because it does not use randomized padding, identical blocks of plain text will yield identical blocks of ciphertext. For bank-level production systems, use the standard cryptography library.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

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

simple_rsa_tartarus8-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

simple_rsa_tartarus8-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file simple_rsa_tartarus8-0.1.0.tar.gz.

File metadata

  • Download URL: simple_rsa_tartarus8-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for simple_rsa_tartarus8-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3b224e5faa38159b38c9aef0ee2037dbb245ca456e1eef4b3d9f0d4952d50e72
MD5 c898cd31852db16986ad7c66ead98b10
BLAKE2b-256 aeafbba2406c386c6e2312e44eddf4c019a59668a7d64a4e9d6c1f91571ad0d4

See more details on using hashes here.

File details

Details for the file simple_rsa_tartarus8-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_rsa_tartarus8-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e0ab935b3208a3fdd1f7cc7d45edcaf232e28eef910b59d5fca245deb9ff98c
MD5 f162d29c23b5ab32ecd94d0f5ce35200
BLAKE2b-256 fc378bcaba6bc961c8f6446b3ae2c1e42671cc3286906d256bc5338305941d30

See more details on using hashes here.

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