/crypto-rust

A more secure AES encryption time-based

Primary LanguageRust

crypto-service-rust

Combining AES with TOTP for a more secure AES encryption. (rust implementation)

Getting started

A new AES key is generated every 30 seconds with the TOTP algorithm. The client needs the original AES key to decrypt the messages but the key-synchronization happens with the help of the TOTP.

Usage

 fn create_cypto() -> Crypto {
        let key = "12345678901234567890123456789012";
        let vec_key = Vec::from(key.as_bytes());
        let iv = "21098765432109876543210987654321";
        let vec_iv = Vec::from(iv.as_bytes());
        let time_key = "00010203040506070809";
        let vec_time_key = Vec::from(time_key.as_bytes());
        let crypto = Crypto::new(vec_key, vec_iv, vec_time_key);
        println!("Crypto created");
        crypto
 }


 let msg_bytes = "Time based tests rust. Secret.!!".as_bytes();
 let msg = Vec::from(msg_bytes);

 let crypto = create_cypto();

 let encrypted = CryptoService::encrypt_time_based(&crypto, &msg);
 let original = CryptoService::decrypt_time_based(&crypto, &encrypted);

 println!("Original {}", String::from_utf8_lossy(&original));