Argon2
Argon2 is a key derivation function (KDF) designed for secure password hashing.
Unlike older algorithms like bcrypt or PBKDF2, Argon2 is designed to:
Resist attacks from GPUs, FPGAs, and ASICs (specialized hardware)
Be configurable in terms of memory, processing time, and parallelism
Provide protection against side-channel attacks (such as timing attacks)
Argon2 Configurable Parameters
time_cost: default: 3 Number of iterations (higher = slower but more secure)
memory_cost: default: 65536 Memory used in KB (e.g., 65536 = 64MB)
parallelism: default: 4 Number of threads used (useful on multi-core machines)
These values offer a good compromise between security and performance, with a typical calculation time around 50–100 ms on a modern machine
Highly secure: Designed to slow brute force attacks
Flexible: Adapts to your environment (server, mobile, etc.)
Recommended: By the IETF as a modern standard for password hashing
Adapt according to context.
Secure server: Increase memory_cost to 131072 or higher.
Mobile or embedded: Reduce memory_cost to 32768 or 16384.
Multi-user: Keep time_cost ≤ 3 to avoid deadlocks.
Scrypt
Scrypt is a hashing algorithm that offers maximum resistance to brute-force attacks, particularly those carried out using specialized hardware such as GPUs or ASICs.
It was designed to make password hashing extremely memory-intensive, making it difficult to parallelize.
Features:
Uses a memory-intensive key bypass function
Ideal for environments where security takes priority over speed
Advantages:
Very robust against hardware attacks
Suitable for modern systems requiring enhanced security
Used in some cryptocurrencies (e.g., Litecoin)