Skip to main content

Cryptography tool based on RSA and AES

Project description

NyxCrypta

Version Python License PRs Welcome

A Python cryptography library combining RSA asymmetric encryption and AES symmetric encryption for efficient and secure data protection.

📑 Table of Contents

Features

  • 🔐 RSA key pair generation with multiple security levels
  • 📄 Multiple key formats support (PEM, DER, SSH)
  • 🔒 File encryption and decryption
  • 💾 Raw data encryption and decryption
  • 🛡️ Strong encryption using RSA + AES hybrid approach
  • 🔄 Key format conversion utilities

Security Levels

Security Level RSA Key Size Recommended Use
Standard 2048-bit General purpose encryption
High 3072-bit Sensitive data protection
Paranoid 4096-bit Maximum security requirements

Installation

From PyPI

pip install nyxcrypta

From Source

git clone https://github.com/Division-of-Cyber-Anarchy/NyxCrypta.git
cd NyxCrypta
pip install -e .

Usage

Key Generation

# Generate PEM format key pair
nyxcrypta keygen -o ./keys -p "your_strong_password" -f PEM

# Generate DER format key pair
nyxcrypta keygen -o ./keys -p "your_strong_password" -f DER

# Generate SSH format public key
nyxcrypta keygen -o ./keys -p "your_strong_password" -f SSH

Key Format Conversion

# Convert PEM to DER
nyxcrypta convert -i ./keys/public_key.pem -o ./keys/key.der --from-format PEM --to-format DER

# Convert DER to SSH (public key only)
nyxcrypta convert -i ./keys/public_key.der -o ./keys/key.ssh --from-format DER --to-format SSH --public

File Encryption/Decryption

# Encrypt a file
nyxcrypta encrypt -i file.txt -o file.nyx -k ./keys/public_key.pem

# Decrypt a file
nyxcrypta decrypt -i file.nyx -o file.txt -k ./keys/private_key.pem -p "your_password"

Data Encryption/Decryption

# Encrypt raw data
nyxcrypta encryptdata -d "My secret data" -k ./keys/public_key.pem

# Decrypt raw data
nyxcrypta decryptdata -d "encrypted_hex_string" -k ./keys/private_key.pem -p "your_password"

Security Features

Feature Description
Hybrid Encryption RSA for key exchange, AES for data encryption
Key Derivation Argon2 for secure password-based key generation
Random Generation Secure random number generation using OS entropy
Multi-level Security Support for different RSA key sizes
Private Key Protection Encrypted storage of private keys

Testing

Run the comprehensive test suite:

nyxcrypta test

Key Format Support

Public Keys

  • PEM format (.pem)
  • DER format (.der)
  • OpenSSH format (.ssh)
  • JSON format (.json)

Private Keys

  • PEM format (.pem)
  • DER format (.der)
  • JSON format (.json)

Python Example

from nyxcrypta import NyxCrypta, SecurityLevel, KeyFormat

# Initialize NyxCrypta
nx = NyxCrypta()  # Uses STANDARD security level by default

# Generate key pair
nx.save_keys("./keys", "your_password", KeyFormat.PEM)

# Encrypt a file
nx.encrypt_file("secret.txt", "secret.nyx", "./keys/public_key.pem")

# Decrypt a file
nx.decrypt_file("secret.nyx", "decrypted.txt", "./keys/private_key.pem", "your_password")

# Encrypt and decrypt data
message = b"Hello, World!"
encrypted = nx.encrypt_data(message, "./keys/public_key.pem")
decrypted = nx.decrypt_data(bytes.fromhex(encrypted), "./keys/private_key.pem", "your_password")
print(decrypted.decode())  # Prints: Hello, World!

# Using higher security level
nx_secure = NyxCrypta(SecurityLevel.PARANOID)
nx_secure.save_keys("./secure_keys", "your_password", KeyFormat.PEM)

# Key format conversion
from nyxcrypta import KeyConverter

# Convert public key from PEM to SSH format
with open("./keys/public_key.pem", "rb") as f:
    pem_data = f.read()
ssh_key = KeyConverter.convert_public_key(pem_data, KeyFormat.PEM, KeyFormat.SSH)
with open("./keys/public_key.ssh", "wb") as f:
    f.write(ssh_key)

# Convert private key from PEM to DER format
with open("./keys/private_key.pem", "rb") as f:
    pem_data = f.read()
der_key = KeyConverter.convert_private_key(
    pem_data,
    KeyFormat.PEM,
    KeyFormat.DER,
    "your_password".encode()
)
with open("./keys/private_key.der", "wb") as f:
    f.write(der_key)

Dependencies

Package Version Purpose
cryptography >=41.0.5 Core cryptographic operations
argon2-cffi >=20.1.0 Password hashing and key derivation
cffi >=1.17.1 C interface for cryptographic operations
tqdm >=4.67 Progress bars for operations

Internal Architecture

Core Components

---
config:
  layout: fixed
  theme: neo-dark
  look: handDrawn
---
graph LR
    A[Hybrid Encryption]
    B[Strong Key Derivation]
    C[Secure Random Number Generation]
    D[Multiple Security Levels]
    E[Encrypted Private Key Storage]

    subgraph "Core Components"
        A -->|Uses| F(RSA for Key Exchange)
        A -->|Uses| G(AES for Data Encryption)
        B -->|Based on| H(Argon2 Algorithm)
        C -->|Provided by| I(Cryptography Library)
        D -->|2048-bit, 3072-bit, 4096-bit| J(RSA Key Sizes)
        E -->|Secured by| B
        E -->|Formats| K(PEM, DER)
    end

    CLI -->|Triggers| A
    CLI -->|Triggers| E
    Utils -->|Supports| B
    Utils -->|Supports| C

Module Structure

  1. Core Functions (core/)

    • crypto.py: Encryption/decryption logic
    • security.py: Key derivation and storage
    • utils.py: Utility functions
    • compatibility.py: Format compatibility
  2. CLI Interface (cli/)

    • commands.py: Command definitions
    • parser.py: Input parsing
  3. Testing (test_runner.py)

    • Automated testing suite
    • Performance metrics

FAQ

What is hybrid encryption?

NyxCrypta uses RSA for secure key exchange and AES for efficient data encryption, combining the strengths of both approaches.

Why use Argon2?

Argon2 provides strong protection against brute-force attacks and is computationally expensive by design.

How secure is the random number generation?

We use os.urandom and the cryptography library's secure random number generators.

What security level should I choose?

  • Standard (2048-bit): General use
  • High (3072-bit): Sensitive data
  • Paranoid (4096-bit): Maximum security

How are private keys protected?

Private keys are encrypted using Argon2-derived keys and stored in encrypted PEM or DER format.

Security Considerations

  • Use strong passwords for private keys
  • Keep private keys secure
  • Choose appropriate security levels
  • Update encryption keys regularly
  • Verify file integrity

Development Status

Current status: Active Development

  • API may change
  • Some experimental features
  • Ongoing security audits

Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

Bug Reports and Feature Requests

Use the GitHub issue tracker

License

MIT License - see LICENSE file

Authors

Division of Cyber Anarchy (DCA)

Contact

GitHub

https://github.com/Division-of-Cyber-Anarchy/


Simplicity is the ultimate sophistication. - Leonardo da Vinci

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

nyxcrypta-1.4.1.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

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

nyxcrypta-1.4.1-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file nyxcrypta-1.4.1.tar.gz.

File metadata

  • Download URL: nyxcrypta-1.4.1.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for nyxcrypta-1.4.1.tar.gz
Algorithm Hash digest
SHA256 03a3a4bff5961c34c5804fd46aa69f7bc78828d153b85169c2fa50a5a1a2b201
MD5 f2d96c6cbb76db5c9f82ab755eceb263
BLAKE2b-256 b7b7533745bc06af25c59e23c5a29636bb01d457932ec4c1fe5cae030dd71093

See more details on using hashes here.

File details

Details for the file nyxcrypta-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: nyxcrypta-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for nyxcrypta-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 72f41f81b9f956609294cdcc830288797a71c70eb12c9b3c35f5c488588e4cc2
MD5 447019b38e9cdea35c151f320be0fb25
BLAKE2b-256 619becab4caaf7989f55b1e2833e0cab45674801c9aca5896b0e5979c2b4b399

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