Bump version
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-04-28 19:50:00 +02:00
parent 1b62a887c8
commit 279adff4f3
3 changed files with 6 additions and 3 deletions

View File

@ -8,8 +8,11 @@ use base64::Engine as _;
pub use bincode::{Decode, Encode};
use rand::Rng;
/// The lenght of the nonce used to initialize encryption
const NONCE_LEN: usize = 12;
/// CryptoWrapper is a library that can be used to encrypt and decrypt some data marked
/// that derives [Encode] and [Decode] traits using AES encryption
pub struct CryptoWrapper {
key: Key<Aes256Gcm>,
}
@ -22,7 +25,7 @@ impl CryptoWrapper {
}
}
/// Encrypt some data
/// Encrypt some data, returning the result as a base64-encoded string
pub fn encrypt<T: Encode + Decode>(&self, data: &T) -> Result<String, Box<dyn Error>> {
let aes_key = Aes256Gcm::new(&self.key);
let nonce_bytes = rand::thread_rng().gen::<[u8; NONCE_LEN]>();