Crates.io | simplestcrypt |
lib.rs | simplestcrypt |
version | 0.1.4 |
source | src |
created_at | 2020-11-18 16:12:14.148815 |
updated_at | 2024-08-21 13:59:57.769077 |
description | 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 |
homepage | |
repository | https://github.com/TotalKrill/simplestcrypt |
max_upload_size | |
id | 313721 |
size | 15,675 |
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
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));
}
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