ring``aes-gcm``chacha20poly1305
AES-256-GCMNonceChaCha20-Poly1305 AES-NI
X25519 + Ed25519 Curve25519 RSA ECDSA
zeroize crate swap HSM TPM
SHA-256 Argon2id ASIC/GPU
use aes_gcm::{Aes256Gcm, Nonce, KeyInit};
use aes_gcm::aead::{Aead, OsRng};
use zeroize::Zeroize;
// AES-256-GCM
fn encrypt(key: &[u8; 32], plaintext: &[u8]) -> Vec<u8> {
let cipher = Aes256Gcm::new_from_slice(key).unwrap();
let nonce = Aes256Gcm::generate_nonce(&mut OsRng);
let ciphertext = cipher.encrypt(&nonce, plaintext).unwrap();
[nonce.as_slice(), &ciphertext].concat()
}
//
let mut key = [0u8; 32];
// ... ...
key.zeroize(); // // Argon2id
use argon2::Argon2;
use password_hash::{SaltString, PasswordHasher, rand_core::OsRng};
fn hash_password(password: &[u8]) -> String {
let salt = SaltString::generate(&mut OsRng);
Argon2::default().hash_password(password, &salt).unwrap().to_string()
}| AES-256-GCM | 128-bit security | |
| ChaCha20-Poly1305 | ||
| X25519 | ||
| Ed25519 | ||
| Argon2id | ||
| SHA-256 |