The Academy is free // the war room is optional
DAEMONCORE // ACADEMY
← FIELD NOTES

Hashing and password storage: what you need to know

2026.09.06//8 MIN READauthenticationcredential-securitysecurity-labsfundamentals

// The hashing misconception

When discussing password security, it's not uncommon to hear terms like "encryption" and "hashing" thrown around interchangeably. This conflation can lead to significant security misunderstandings, especially for those new to the field. Let's clarify what hashing is, what it isn’t, and why passwords should be hashed rather than encrypted.

// What is hashing?

Hashing is a one-way function that takes an input (or 'message') and produces a fixed-size string of characters, which is typically a sequence of numbers and letters. This unique string is known as a hash. Importantly, the same input will always produce the same hash, making it easy to verify data integrity without revealing the actual input.

Example of hashing

Consider the following command using the sha256sum utility on a Linux system to hash a password:

echo -n 'mypassword' | sha256sum

Output: 6c570f1f3b2b2c4b8f6c9b8f2c6f644c3b62cbb52b6eecf5e9debe6b6d8a6d8e0

What just happened? The command takes the plaintext password 'mypassword' and converts it into a SHA-256 hash. Note the use of -n with echo to prevent a newline character from being added, which would change the hash.

// What is not hashing?

1. Not reversible: Unlike encryption, which can be decrypted with the appropriate key, hashing is designed to be irreversible. Once data is hashed, you cannot retrieve the original data from the hash without resorting to brute force or dictionary attacks. 2. Not encryption: Hashing does not use keys and is not meant to be reversible. It simply generates a hash digest that can be compared against another hash without exposing the original input.

// Why passwords shouldn’t be encrypted

Encrypting passwords can create a false sense of security. Since encryption is reversible, if an attacker gains access to the encrypted passwords and the encryption key, they could easily decrypt them and access user accounts. Instead, hashing offers a way to store passwords securely without the risk of them being easily recovered.

Hashing in practice

When storing passwords, it's crucial to use a strong and adaptive hashing algorithm, such as bcrypt, Argon2, or PBKDF2. These algorithms are designed to be slow, making brute-force attacks more difficult. Here’s how you can use bcrypt in Python:

import bcrypt

password = b'mypassword'  # Password to hash

# Generate a salt and hash the password
hashed = bcrypt.hashpw(password, bcrypt.gensalt())
print(hashed)

In this code, bcrypt.gensalt() generates a unique salt for the password before hashing it. The resulting hashed password is what should be stored in your database.

// Common mistakes to avoid

  • Using unsalted hashes: Always use a unique salt for each password to defend against rainbow table attacks.
  • Choosing weak algorithms: Avoid algorithms like MD5 or SHA-1 for password hashing; they are no longer considered secure.
  • Failing to implement rate limiting: Protect your systems from brute-force attacks by limiting the number of login attempts.

// Defensive implications

For effective password security, follow these guidelines:

  • Use adaptive hashing algorithms: They increase the time required to hash passwords, which is advantageous in slowing down potential attackers.
  • Store only hashes: Never store plaintext passwords or even encrypted passwords. Only store the hash.
  • Implement account lockout mechanisms: After a certain number of failed login attempts, lock the account temporarily to hinder attacks.

Checklist for secure password storage

  • [ ] Use a unique salt for each password.
  • [ ] Choose a strong, adaptive hashing algorithm.
  • [ ] Never log or expose plaintext passwords.
  • [ ] Implement rate limiting on login attempts.

// Conclusion

Understanding the difference between hashing and encryption, and applying the correct practices for password storage, can safeguard your systems against unauthorized access. Remember, hashing is a one-way street — once you go down it, you can’t turn back, and that’s a good thing when it comes to protecting user data.

For practical exercises, the DaemonCore Academy curriculum provides free resources to help you test these concepts in a disposable lab environment you control.