#data-transfer #drop #encryption #symmetric #key #wrapper #symmetric-encryption #kind #advanced #aes-siv

simplestcrypt

Simplest way to perform a symmetric encryption, using a preshared key. Very small wrapper around aes-siv crate, with randomly generated nonces, for anything more advanced, use aes-siv instead

4 releases

0.1.3 Mar 24, 2022
0.1.2 Nov 19, 2020
0.1.1 Nov 18, 2020
0.1.0 Nov 18, 2020

#830 in Cryptography

Download history 33/week @ 2022-08-12 25/week @ 2022-08-19 18/week @ 2022-08-26 35/week @ 2022-09-02 16/week @ 2022-09-09 25/week @ 2022-09-16 61/week @ 2022-09-23 9/week @ 2022-09-30 23/week @ 2022-10-07 8/week @ 2022-10-14 20/week @ 2022-10-21 8/week @ 2022-10-28 14/week @ 2022-11-04 38/week @ 2022-11-11 9/week @ 2022-11-18 24/week @ 2022-11-25

89 downloads per month

MIT license

7KB
77 lines

simplestcrypt

Simplest way to perform a symmetric encryption, using a preshared key. Very small wrapper around aes-siv crate, with randomly generated nonces, for anything more advanced, use aes-siv instead

Example

use std::str;
fn main() {
    let payload = "Hello world!".as_bytes();
    let password = b"hello wooooooooo";

    let encrypted = simplestcrypt::encrypt_and_serialize(&password[..], &payload).unwrap();
    let plain = simplestcrypt::deserialize_and_decrypt(&password[..], &encrypted).unwrap();

    println!("{:?}", str::from_utf8(&plain));
}

Serialization notes

Bincode adds 8 bytes in between the serialized nonce and the serialized ciphertext so it looks like:

Bytes Description
0 - 15 Nonce used when encrypting the ciphertext
16 - 23 The lenght of the cyphertext
24 - .. Cyphertext

This needs to be taken into account when interoperating with other libraries

Dependencies

~3.5MB
~48K SLoC