SECURITY / A CONCEPT NOTE
Hashing vs Encryption
one-way vs two-way
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
Hashing is a one-way mathematical function that outputs a fixed-length string (like SHA256) and cannot be reversed. Encryption is a two-way function that can be reversed using a secret key.
02 / FOLLOW THE MECHANISM
How hashing vs encryption flows
Hash check
system hashes user password at login and compares the result to the stored database hash.
Encryption run
encrypts database data (ciphertext) before writing to disk.
Decryption run
reads ciphertext from disk, applying key to decrypt it back to plaintext.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
generate a SHA256 hash of a string
echo -n "password" | sha256sumencrypt a file symmetrically with a passphrase
gpg -c secrets.txt05 / CHECK YOURSELF
Could you explain Hashing vs Encryption to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.
Up next in Security & identityCertificates & PKIwhy browsers trust anyone