crypt-ro 0.3.0

Blazing-fast matrix-based encryption library with configurable transformations
Documentation
# Crypt-ro - Blazing Fast Matrix-Based Cryptographic Library

[![Crates.io](https://img.shields.io/crates/v/crypt-ro)](https://crates.io/crates/crypt-ro)
[![Documentation](https://docs.rs/crypt-ro/badge.svg)](https://docs.rs/crypt-ro)
[![License](https://img.shields.io/crates/l/crypt-ro)](LICENSE)


A high-performance Rust library implementing lightning-fast matrix-based cryptographic operations that outperform traditional algorithms like RSA in most use cases.

## Why Choose Crypt-ro?

🚀 **10-100x faster than RSA** for typical payloads  
🔒 **Secure by design** with multiple protection layers  
⚡ **Near-native performance** thanks to Rust optimization
âœĻ **Text-friendly** URL-safe base64 encoding
ðŸ§Đ **Support** for both raw bytes and text operations
🔄 **Perfect for** high-throughput applications like:
- Real-time messaging
- Database encryption
- Game networking
- IoT device communication


## Features

- **Lightning-fast operations** optimized
- **Constant-time operations** resistent to timing attacks
- **Minimal overhead** with efficient memory usage
- **Thread-safe design** for parallel processing


## Installation

Add to your `Cargo.toml`:

```toml
[dependencies]
crypt-ro =  "0.1.0"
```

## Usage Example

```rust
use crypt_ro::Cryptor;

fn process_chat_messages() {
    let cryptor = Cryptor::new();
    let key = "session-key-abc123";
    
    // Encrypt 1000 messages in milliseconds
    let messages: Vec<String> = /* ... */;
    let encrypted: Vec<_> = messages.iter()
        .map(|msg| cryptor.encrypt_text(msg, key).unwrap())
        .collect();
    
    // Decrypt just as fast
    let decrypted: Vec<_> = encrypted.iter()
        .map(|cipher| cryptor.decrypt_text(cipher, key).unwrap())
        .collect();
}
```

### Basic Text Encryption

```rust
use crypt_ro::Cryptor;

fn test(){
    let cryptor = Cryptor::new();
    let secret = "My confidential message";
    let key = "strong-password-123";

    // Encrypt
    let encrypted = cryptor.encrypt_text(secret, key).unwrap();

    // Decrypt
    let decrypted = cryptor.decrypt_text(&encrypted, key).unwrap();

    assert_eq!(decrypted, secret);
}
```

### Binary Data Encryption

```rust
use crypt_ro::Cryptor;

fn test(){
    let cryptor = Cryptor::new();
    let data = b"\x01\x02\x03binary\xff\xfe\xfd";
    let key = "encryption-key";

    // Encrypt raw bytes
    let encrypted = cryptor.encrypt(data, key).unwrap();

    // Decrypt
    let decrypted = cryptor.decrypt(&encrypted, key).unwrap();

    assert_eq!(decrypted, data);
}
```

### Custom Matrix Size

```rust
use crypt_ro::Cryptor;

fn test(){
    let mut cryptor = Cryptor::new();
    cryptor.set_matrix(64); // Use 64-byte blocks

    let encrypted = cryptor.encrypt_text("data", "key").unwrap();
    let decrypted = cryptor.decrypt_text(&encrypted, "key").unwrap();

    assert_eq!(decrypted, "data");
}
```

## When to Use

✅ **High-volume encryption** (logging, metrics, telemetry)  
✅ **Low-latency requirements** (real-time systems)  
✅ **Resource-constrained environments**  
✅ **Temporary data protection** (session tokens, cache)


## Performance

Crypt-ro delivers **blazing-fast** encryption/decryption speeds, competitive with industry-standard algorithms:

| Algorithm   | Operation | 50B Data   | Comparison          |
|-------------|-----------|------------|---------------------|
| Crypt-ro    | Encrypt   | 530-550 ns | ~1.1x AES-256       |
| Crypt-ro    | Decrypt   | 260-280 ns | **Faster** than AES |
| AES-256-GCM | Encrypt   | 456-457 ns | Reference           |
| AES-256-GCM | Decrypt   | 439-460 ns | Reference           |
| RSA-2048    | Encrypt   | 168-171 Ξs | ~250x slower        |
| RSA-2048    | Decrypt   | 1.3-1.4 ms | ~3000x slower       |

**Key Advantages:**
- ⚡ **Sub-microsecond** operations for small data
- ðŸ”Ĩ Decryption is **15-20% faster** than AES-256-GCM
- 🚀 **3000x faster** than RSA for decryption


## Security Considerations

While extremely fast, Crypt-ro uses:
- Random initialization vectors
- Multiple transformation layers
- Defense in depth strategy
Security Notes
- This library uses a custom encryption algorithm - not peer-reviewed
- Not recommended for highly sensitive data
- Always use strong, complex keys


## Contributing

Contributions are welcome! Please open an issue or pull request on GitHub.


## License

Dual-licensed under [MIT](LICENSE-MIT) or [Apache 2.0](LICENSE-APACHE) at your option.