A hash function is a mathematical function that takes an input of arbitrary size and produces a fixed-size output (hash value, digest). A cryptographic hash function must have three core properties. One-wayness (Pre-image Resistance): the original input cannot be recovered from the hash value. Collision Resistance: finding two inputs that produce the same hash is practically infeasible. Avalanche Effect: a small change in the input causes a drastic change in the output.
Hash functions are classified by purpose. General-purpose hash functions (SHA-256, SHA-3, BLAKE3) are used for data integrity verification, digital signatures, and blockchain. Password hashing functions (Argon2, bcrypt, scrypt) are intentionally designed to be slow, making brute-force attacks difficult. Argon2, the winner of the 2015 Password Hashing Competition, is the best choice as of 2025, and OWASP also recommends Argon2id as the top priority.
The key to password storage is Salt and an appropriate Work Factor. A Salt is a random value generated for each password, which prevents Rainbow Table attacks. Modern algorithms such as Argon2 and bcrypt handle Salt automatically. The Work Factor (Cost Factor) is the amount of computation/memory required for hashing, and it should be increased gradually in line with improvements in hardware performance. OWASP recommends a minimum of 19MiB of memory and 2 iterations for Argon2id, and 128MiB and 3-5 iterations for security-critical systems.
bcrypt is old but still secure. However, it is more vulnerable than Argon2 to GPU-based attacks. This is because Argon2 is a memory-hard algorithm, which makes large-scale parallel cracking difficult given the limited memory of GPUs. bcrypt's 72-byte password limit must also be taken into account. If you use bcrypt in a legacy system, set the Cost Factor to 12 or higher. For new projects, it is better to choose Argon2id. Adding a Pepper (a server-side secret key) provides an additional layer of protection even if the database is leaked.