// Encrypt plaintext string using provided secret and IV
Encrypt plaintext string using provided secret and IV
Encrypt plaintext string using provided secret and IV
fn aes_256_gcm_siv_encrypt(secret: String, iv: Vec<u8>, plaintext: String) -> Vec<u8> {
    // load key from secret
    let key = GenericArray::from_slice(secret.as_bytes());
    // Initialize AES256GCM
    let cipher = Aes256GcmSiv::new(key);
    // Set the noce to the IV
    let nonce = GenericArray::from_slice(&iv);
    // Encrypt returning the result
    cipher
        .encrypt(nonce, plaintext.as_bytes().as_ref())
        .expect("encryption failure!")
}
fn aes_256_gcm_siv_encrypt ( secret : String , iv : Vec < u8 > , plaintext : String ) -> Vec < u8 > { // load key from secret let key = GenericArray :: from_slice ( secret . as_bytes ( ) ) ; // Initialize AES256GCM let cipher = Aes256GcmSiv :: new ( key ) ; // Set the noce to the IV let nonce = GenericArray :: from_slice ( & iv ) ; // Encrypt returning the result cipher . encrypt ( nonce , plaintext . as_bytes ( ) . as_ref ( ) ) . expect ( " " ) }
Encrypt plaintext string using provided secret and IV
Encrypt plaintext string using provided secret and IV
secret
String
iv
Vec<u8>
plaintext
String