Updated all dependencies.

This commit is contained in:
Revertron
2025-10-27 01:22:02 +01:00
parent 61f2d89ef1
commit 81f5568957
5 changed files with 369 additions and 241 deletions
+9 -4
View File
@@ -15,9 +15,14 @@ pub struct Chacha {
impl Chacha {
pub fn new(key: &[u8], nonce: &[u8]) -> Self {
let key = Key::from_slice(key);
let cipher = ChaCha20Poly1305::new(key);
let nonce = Nonce::clone_from_slice(nonce);
// Convert slices to fixed-size arrays, then to GenericArray
let key_array: [u8; 32] = key.try_into().expect("Key must be 32 bytes");
let key = Key::from(key_array);
let cipher = ChaCha20Poly1305::new(&key);
let nonce_array: [u8; 12] = nonce.try_into().expect("Nonce must be 12 bytes");
let nonce = Nonce::from(nonce_array);
Chacha { cipher, nonce }
}
@@ -30,7 +35,7 @@ impl Chacha {
}
pub fn get_nonce(&self) -> &[u8] {
&self.nonce.as_slice()
self.nonce.as_ref()
}
}