diff --git a/Cargo.lock b/Cargo.lock index 032dbb5..6b3829f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -478,7 +478,7 @@ checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "light-openid" -version = "0.1.0-alpha" +version = "0.2.0-alpha" dependencies = [ "aes-gcm", "base64", diff --git a/Cargo.toml b/Cargo.toml index 692e97d..68d520c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "light-openid" -version = "0.1.0-alpha" +version = "0.2.0-alpha" edition = "2021" repository = "https://gitea.communiquons.org/pierre/light-openid" authors = ["Pierre HUBERT "] diff --git a/src/crypto_wrapper.rs b/src/crypto_wrapper.rs index 6263712..3e09ba0 100644 --- a/src/crypto_wrapper.rs +++ b/src/crypto_wrapper.rs @@ -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, } @@ -22,7 +25,7 @@ impl CryptoWrapper { } } - /// Encrypt some data + /// Encrypt some data, returning the result as a base64-encoded string pub fn encrypt(&self, data: &T) -> Result> { let aes_key = Aes256Gcm::new(&self.key); let nonce_bytes = rand::thread_rng().gen::<[u8; NONCE_LEN]>();