rusty_crypt 0.2.0

Rust library allowing for a very quick and simple implementation of AES-GCM encryption
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::error::CryptoError;

pub struct AesGcmGeneratedNonce;

impl AesGcmGeneratedNonce {
    pub fn generate_nonce(&self) -> Result<[u8; 12], CryptoError> {
        let mut nonce_bytes = [0u8; 12];

        getrandom::fill(&mut nonce_bytes).map_err(|_| CryptoError::RandomGenerationFailed)?;

        Ok(nonce_bytes)
    }
}