| Crates.io | tcrypt |
| lib.rs | tcrypt |
| version | 0.1.2 |
| created_at | 2025-03-20 19:37:37.824622+00 |
| updated_at | 2025-03-20 19:37:37.824622+00 |
| description | A secure cryptographic library for key exchange and encryption |
| homepage | |
| repository | https://github.com/ThatOneToast/tcrypt |
| max_upload_size | |
| id | 1599690 |
| size | 68,084 |
tcrypt is a secure cryptographic library for Rust that provides tools for encryption, key exchange, and secure channel communication. It implements modern cryptographic primitives using the X25519 key exchange protocol and AES-GCM for symmetric encryption, with optional support for post-quantum cryptography.
Classical Cryptography
Password-Based Encryption
Quantum-Resistant Cryptography (optional)
use tcrypt::key_management::wrappers::{ClientKeyExchange, ServerKeyExchange};
use tcrypt::key_exchange::protocol::SecureChannel;
// Initialize client and server
let mut client = ClientKeyExchange::new();
let mut server = ServerKeyExchange::new();
// Perform key exchange
let client_public = client.initiate_exchange();
let (server_public, server_secret) = server.respond_to_exchange(client_public).unwrap();
let client_secret = client.complete_exchange(server_public).unwrap();
// Create secure channels
let client_channel = SecureChannel::new(&client_secret).unwrap();
let server_channel = SecureChannel::new(&server_secret).unwrap();
// Use channels for secure communication
let message = b"Secret message";
let encrypted = client_channel.encrypt(message).unwrap();
let decrypted = server_channel.decrypt(&encrypted).unwrap();
assert_eq!(&decrypted, message);
use tcrypt::password::secure::{pcrypt, pdecrypt};
// Encrypt data with password
let password = "my-secure-password";
let data = "sensitive information";
let encrypted = pcrypt!(password, data).unwrap();
// Decrypt data using the same password
let decrypted = pdecrypt!(password, &encrypted).unwrap();
assert_eq!(decrypted, data.as_bytes());
// This requires the "quantum" feature to be enabled
use tcrypt::quantum::wrappers::{QuantumClientExchange, QuantumServerExchange};
// Initialize quantum-resistant key exchange
let mut client = QuantumClientExchange::new();
let mut server = QuantumServerExchange::new();
// Exchange keys using CRYSTALS-Kyber
let server_public = server.public_key();
let (client_secret, ciphertext) = client.complete_exchange(server_public).unwrap();
let server_secret = server.respond_to_exchange(&ciphertext).unwrap();
assert_eq!(client_secret, server_secret);
quantum: Enables quantum-resistant cryptography features using CRYSTALS-KyberAdd this to your Cargo.toml:
[dependencies]
tcrypt = "0.1.2"
# Or, to enable quantum-resistant features:
tcrypt = { version = "0.1.2", features = ["quantum"] }
This project is licensed under the MIT License.