Crate crypt_ro

Crate crypt_ro 

Source
Expand description

A cryptographic library providing matrix-based encryption and decryption.

This library implements a custom encryption scheme using:

  • Matrix transformations with configurable size
  • Key-derived shuffling operations
  • Random padding and mixing operations
  • URL-safe base64 encoding for text operations

§Features

  • Configurable matrix size for transformation blocks
  • Both raw byte and text-friendly operations
  • Key-based encryption/decryption
  • Randomized padding for better security

§Examples

Basic usage:

use crypt_ro::Cryptor;

let cryptor = Cryptor::new();
let secret = "my secret message";
let key = "strong password";

// Encrypt and decrypt text
let encrypted = cryptor.encrypt_text(secret, key).unwrap();
let decrypted = cryptor.decrypt_text(&encrypted, key).unwrap();

assert_eq!(decrypted, secret);

// Using custom matrix size
let mut cryptor = Cryptor::new();
cryptor.set_matrix(64);  // Use larger blocks
let encrypted = cryptor.encrypt_text(secret, key).unwrap();
let decrypted = cryptor.decrypt_text(&encrypted, key).unwrap();

assert_eq!(decrypted, secret);

Working with raw bytes:

use crypt_ro::Cryptor;

let cryptor = Cryptor::new();
let data = b"binary data \x01\x02\x03";
let key = "encryption key";

let encrypted = cryptor.encrypt(data, key).unwrap();
let decrypted = cryptor.decrypt(&encrypted, key).unwrap();

assert_eq!(decrypted.as_bytes(), data);

Structs§

Cryptor
A cryptographic utility for encrypting and decrypting text using a matrix-based transformation.