i was trying to do a encryption and decryption in rust using aes-gcm , so here is the encryption code
pub fn encrypt(data: &[u8], password: &str) {
let password_byte = password.as_bytes();let key: &Key<Aes256Gcm> = password_byte.into(); let cipher = Aes256Gcm::new(&key); let nonce = Aes256Gcm::generate_nonce(&mut OsRng); println!("{:?}", nonce); let encrypted_data = match cipher.encrypt(&nonce, data) { Ok(encrpted) => { encrpted } Err(err) => { vec![0u8; 32] } };
so far encryption is working properly , it is the decryption part im trying to understand , theoretically decryption consist of three parts
1)IV
2)Salt
3) encrypted data
how to split them and ecrypt the data in rust