whoami9894
96 天前
有没有可能,不用写那么多类型标注
另外,函数当然不可能接收 [u8; const N] 参数,难道你能在编译期知道数据长度?
```
let key = Aes256Gcm::generate_key(OsRng);
let cipher = Aes256Gcm::new(&key);
let nonce = Aes256Gcm::generate_nonce(OsRng);
let plaintext = b"plaintext message";
let ciphertext = cipher.encrypt(&nonce, plaintext.as_slice()).unwrap();
let plaintext = cipher.decrypt(&nonce, ciphertext.as_slice()).unwrap();
assert_eq!(&plaintext, b"plaintext message");
```