How to securely encrypt a file with an insecure password in Rust

# · ✸ 54 · 💬 36 · 2 years ago · kerkour.com · sylvain_kerkour · 📷
Today, we are going to see how to securely encrypt data using an insecure password. By using a Password-based Key Derivation Function, we can turn our insecure password into a secure random key. Argon2id let's you specify how much resources it is going to use to hash your password which is also the resources an attacker is going to use for each guess of a bruteforce attack. The code above turns an insecure password password into a secure 32 bytes key that can then be used for encryption. Encrypted"; encrypt file(&file, &dist, &password)?; password. Generate the key with Argon2id from password and salt. Of course, you can't expect this system to protect your data if your password is password.
How to securely encrypt a file with an insecure password in Rust



Send Feedback | WebAssembly Version (beta)