encrypt_and_serialize

Function encrypt_and_serialize 

Source
pub fn encrypt_and_serialize(
    password: &[u8],
    bytes: &[u8],
) -> Result<Vec<u8>, EncryptError>
Expand description

Encrypts the given bytes using a random nonce using Aes128SivAed, and then serializes the encryption along with the nonce using bincode. The resulting vector is then bincode serialized Encrypted structure

Password cannot be longer than 32 bytes

Examples found in repository?
examples/simple.rs (line 7)
2fn main() {
3    let payload = "Hello world!".as_bytes();
4    let password = b"hello wooooooooo";
5
6    println!("Payload: {:?}", payload);
7    let encrypted = simplestcrypt::encrypt_and_serialize(&password[..], &payload).unwrap();
8    println!("Encrypted: {:?}", encrypted);
9    let plain = simplestcrypt::deserialize_and_decrypt(&password[..], &encrypted).unwrap();
10
11    println!("Decrypted: {:?}", &plain);
12}