Cyberlium

Ethical › Module 20 › Lesson 1

BeginnerModule 20Lesson 1/5

Hashing vs Encryption (CEH Recap)

Carry Topic 8: one-way fingerprints vs lockboxes.

15 min+40 XP4 quiz
Module progress1 of 5

Visual · hash_vs_encrypt_fingerprint

A hash is a one-way fingerprint of bytes you own. Encryption is a lockbox with a key. Testers mix the verbs and then reach for hashcat. This lesson keeps them apart.

Opening

A fingerprint is not a lockbox. SHA-256 does not hide a file, and this course is not a cracking shop.

Modules 1–19 kept every lab on a box, phone, network, or cloud account YOU own: written RoE, loopback scans, CVE tickets instead of shells, hashes as defense, no malware samples, sniffing on localhost, no phish kits, no floods, cookie flags as hygiene, firewalls you configure rather than evade, parameterized SQL, home Wi-Fi only, gadgets and tenants you administer. Module 20 is the cryptography domain mapped back onto Topic 8 — hashing, encryption, TLS, and key hygiene — in the authorized-tester frame. The first sentence you must still be able to say out loud is the Topic 8 sentence: a cryptographic hash is a one-way fingerprint. Encryption is a lockbox with a key. They are not the same operation. People still write “passwords are encrypted with SHA-256” in reports. That sentence is wrong, and it trains the next wrong sentence: “so I will hashcat the dump to prove it.” This is original Cyberlium teaching mapped to the CEH v13 cryptography domain — not official EC-Council training, not a certification, not exam dumps, and completing it does not grant CEH. You will hash a string and a tiny file YOU created under $HOME/cyberlium-lab. You will write that hashing is not encryption. You will not invert hashes. You will not download rainbow tables. You will not point hashlib at /etc/shadow, a HaveIBeenPwned paste, or a classmate’s disk. You will not run hashcat, John, or Hydra against anyone’s verifiers. Next lesson is TLS on the Wire During a Test: the padlock is not “the site is safe,” and you inspect certificates on hosts in scope — example.com as public documentation literacy, not a fake CA against a family tablet.

1. Carry Topic 8: a hash is a fixed-width one-way fingerprint of bytes

A cryptographic hash function takes input of any size — a password string, a 4 KB notes file, an installer — and produces a fixed-length digest. SHA-256 always yields 256 bits, usually printed as 64 hexadecimal characters. The input can be one byte or a gigabyte; the digest width does not grow. Deterministic means the same input always yields the same digest on every honest implementation. That is why comparing your local hex to a published hex is a real integrity check — provided you obtained the published hex from a channel you already trust, not from a forum next to a cracked download. Matching hex means the bytes you hashed now equal the bytes that were hashed then. It does not mean the file is safe, signed, or from a vendor. Malware can be hashed too; the digest would just be stable. You already practiced this as a defender in Topic 7 and Topic 8: SHA-256 of a file you wrote, then the same file after an edit, then two hex strings that no longer matched. That was integrity. Same bytes, same digest. Change one character, and the digest looks unrelated — avalanche.

One-way (preimage resistance) means that given a digest, it should be computationally infeasible to find any input that produces it. You are not supposed to “decrypt” SHA-256. There is no inverse function with a key. For integrity of files you own, you never need to invert: you re-hash the file you have and compare. MD5 and SHA-1 left the security toolkit in Topic 8 because collisions became practical; SHA-256 is the family this lab uses. You hash contents, not the filename. Open files in binary mode ("rb") so a platform newline rewrite does not change the digest by accident. This course does not turn you into a cracking shop.

Command guide

Hash is a fingerprint — WHAT/WHY (Topic 8 carry)

═══ INSTALL ═══

Linux (Debian/Ubuntu):

Command — copy this

sudo apt install python3

macOS:

Command — copy this

brew install python3

Windows: Download https://python.org/downloads/

═══ COMMANDS ═══

Command — copy this

python3 - << 'PY'
import hashlib
print(hashlib.sha256(b'cyberlium-lab-only').hexdigest())
print('one_way_fingerprint: cannot invert; refuse hashcat dumps')
PY

2. Encryption is a lockbox: ciphertext comes back as plaintext if you hold the key

Encryption is two-way with a key. Encrypt(plaintext, K) → ciphertext. Decrypt(ciphertext, K) → plaintext. AES-GCM and ChaCha20-Poly1305 are the boring modern names for hiding bytes in transit or at rest when you have a key-management story. Anyone can hash; hashing is not a confidentiality control by itself. If you SHA-256 a file and email the digest, you did not hide the file. You produced a fingerprint others can recompute if they have the same bytes. If you SHA-256 a password and store only the hex, you hid the password from casual reading, but you did not encrypt it: there is no key to reverse the digest. Call it a stored verifier, not “encrypted password.” Confusing the two leads to bad designs and bad findings: people “encrypt” passwords with SHA-256 and think a stolen database is harmless, or they treat a hash as a secret that must never be published — while vendor checksums are supposed to be public so you can check a download. Use hashing when the job is verify or store-a-verifier. Use encryption when the job is hide bytes from someone who should not read them, and you can say where the key lives.

Asymmetric cryptography (RSA, ECDSA, TLS certificates in Lesson 2) is still a lockbox family: a public key may be published; a private key must not. This lesson does not re-teach AES modes or RSA math. It re-teaches the verbs so a student does not “graduate” into hashcat because a blog titled with a cert acronym said Module 20 is cryptanalysis. Authorized crypto work here is literacy plus YOUR bytes. Homebrew XOR, verify=False, and “broken ciphers to practice on classmates” stay refused. A CEH-shaped vocabulary does not create a cracking warrant.

3. What testers mix up: “encrypted SHA-256,” MFA as a hash, and dumps as homework

In a report, “the application encrypts passwords with SHA-256” is a finding written by someone who failed this lesson. The accurate sentence is: the application stores a hash of the password — and raw SHA-256 without a unique salt and a slow KDF is a worse storage finding. Encryption would mean a key exists that turns ciphertext back into the password, which is a terrible way to store passwords. Password storage wants a slow salted hash (Argon2, bcrypt, scrypt — named in Topic 8). MFA is not a hash and not encryption: it is a second factor the surprise message or stolen table cannot complete. Skipping MFA because “we hashed the password” mixes three controls. Unique passwords kill stuffing. MFA survives a stolen password. None of those sentences is a hashcat lab.

Dumps, /etc/shadow, HaveIBeenPwned pastes, and “just a small wordlist against this hex I found” are out of this course the same way café nmap was out of Module 3. Skill does not create consent. A public breach dump is still other people’s secrets. Hashcat, John the Ripper, Hydra, and rainbow tables are named here so you can refuse them, not so you can install them. Topic 8’s optional “tiny list you wrote of a toy word you chose” was a feeling for why unsalted fast hashes of short words are guessable — your word, your list, your notes. It was never a license to attack a dump. Module 20 does not reopen that door. If a teammate pastes a shadow line into Discord as “CEH crypto,” you treat it like a secret in a report (Lesson 3): do not amplify, do not crack, lock your own notes without the stolen verifier.

4. Integrity in a test: hash evidence YOU created — not a classmate’s disk

The defender habit is: obtain expected SHA-256 from a trusted channel, hash the bytes you have, compare as strings. Mismatch → do not run the installer. Match → the bytes equal the published bytes, not “this is malware-free.” Inside an authorized test, the same primitive labels evidence you collected from systems in scope: a config export YOU were allowed to copy, a log snippet from YOUR lab listener, a file you authored for the lab. Hash the copy you stored under cyberlium-lab so you can later prove the bytes did not drift. That is chain-of-custody literacy, not a trophy of other people’s home directories. You may hash every file in cyberlium-lab because you created that tree. You may not hash a coworker’s laptop “to see.” You may not hash /etc/shadow “because it is a file.” Empty notes fail. Notes that contain other people’s hashes, shadow lines, or a paste from a breach dump fail ethics even if SHA-256 ran.

Carry Topic 7’s engineering: chunked update so large files fit in RAM, open(path, "rb"), hexdigest() or openssl dgst -sha256, notes in $HOME/cyberlium-lab, chmod 600. Do not hash the filename and call it file integrity. Do not “encrypt” a file by hashing it. Do not “hash” a file by running AES. Keep the verbs separate in notes you will actually reread when you write Lesson 3’s report hygiene. A useful feeling: the lesson is “too small” because you did not recover a plaintext from a hex. That feeling is how people leave literacy and enter unauthorized cracking. The skill is stopping. Lesson 4 will let you re-hash a file YOU created and recheck example.com certificate fields — still integrity and public documentation, still not hashcat.

5. What you record: hashing ≠ encryption, YOUR hexes, refuse line, locked notes

A hash-versus-encrypt note is boring on purpose. Date (UTC). Hashing means one-way fixed-size fingerprint: deterministic, avalanche, no key, no decrypt. Encryption means lockbox: ciphertext returns to plaintext with the key. Password storage is a slow salted hash, not “encrypted SHA-256,” and MFA is a second factor — not a digest. Ethics: NEVER hashcat, NEVER John, NEVER Hydra, NEVER rainbow tables, NEVER /etc/shadow, NEVER HaveIBeenPwned, NEVER a classmate’s files. Legal line: original Cyberlium teaching mapped to the CEH v13 cryptography domain — not official EC-Council training, not a cert, not exam dumps. Notes path: $HOME/cyberlium-lab/hash-vs-encrypt-notes.txt, chmod 600. Empty files fail. Files that list dumped hashes fail even if you “only planned.” World-readable 777 fails.

Write two hexes you actually produced: SHA-256 of a known string you typed, and SHA-256 of a tiny file you authored. After a one-character edit, write the new file hex and MATCH/DIFFER. That is enough avalanche. Do not add a password list to make it “more crypto.” Do not paste a production key. Next lesson inspects TLS on the wire during a test — still no MITM. A cert acronym in a blog title is not a warrant to crack or intercept.

6. Wrong vs right: hashcat / dumps vs one-way fingerprints of bytes you own

Worked failure — same hashlib.sha256, opposite job. Right never inverts dumps, never hashes /etc/shadow, never treats a digest as ciphertext.

  • Wrong

    Call hashing “encryption” and store SHA-256(password) as if a stolen database were harmless. Skip MFA because “the hash is the second factor.” Download rainbow tables. Run hashcat, John, or Hydra against a dump, /etc/shadow, or HaveIBeenPwned. Hash a coworker’s disk. Skip the lab folder and write digests into a world-readable Downloads folder. Treat Module 20 as a cracking shop and this path as official CEH training. It is not.

  • Right

    Treat a hash as a one-way fixed-size fingerprint: deterministic, avalanche, not reversible with a key. Treat encryption as a lockbox that needs a key. Hash a string and a file you created under $HOME/cyberlium-lab. Record hexes, MATCH/DIFFER after an edit, and the sentence “hashing is not encryption.” Unique passwords plus MFA remain the account controls. chmod 600 the notes. Next: TLS on the Wire During a Test — padlock is not “site is safe.”

7. Hands-on: hashlib of YOUR string and YOUR file, then lock the notes

On a computer you own, create cyberlium-lab if needed, write a tiny text file you authored, print SHA-256 of a known string and of that file’s bytes. Change one character in the file, hash again, confirm the digest moved. Fill hash-vs-encrypt-notes.txt with both hexes, the avalanche observation, hashing ≠ encryption, the MFA/password-storage sentence, and the refuse line. Do not add a dump. Do not hash /etc/passwd “because it is a file.” chmod 600 the script, the demo file, and the notes. Windows: WSL, Git Bash, or py plus a restricted ACL on the notes.

Mission: hash-vs-encrypt-notes.txt in cyberlium-lab (mode 600)

1) Hash a known string and a tiny file YOU authored. Edit one character, hash again, record MATCH/DIFFER (avalanche). 2) Fill $HOME/cyberlium-lab/hash-vs-encrypt-notes.txt with hashing ≠ encryption, password-storage vs MFA sentences, legal line, and ethics refuse line. chmod 600. 3) Ethics: no hashcat, John, Hydra, rainbow tables, /etc/shadow, HaveIBeenPwned, or classmate files.

Stuck? Ask Cyberlium AI Mentor

If “I cannot learn crypto without recovering a password from a hex” still feels true, ask for a hint — not a hashcat line. Try: "Hint only: why a hash is a one-way fingerprint, why encryption needs a key, why MFA is not a digest, and where locked hash-vs-encrypt-notes.txt lives?" You still fill the file. No dumps. No /etc/shadow. No hashcat.

You now treat hashing as a one-way fingerprint of bytes you own and encryption as a lockbox that needs a key. Password storage is a slow salted hash, not “encrypted SHA-256.” MFA is a second factor, not a digest. Notes are locked in cyberlium-lab. This is original Cyberlium teaching mapped to the CEH v13 cryptography domain — not official EC-Council training, not a cert, not exam dumps. Next — TLS on the Wire During a Test — the padlock is not “the site is safe.” You inspect certificates on hosts in scope. example.com public cert literacy is allowed. MITM and fake CAs against others are not.

Knowledge Check

1

APPLY: A teammate pastes a HaveIBeenPwned hex into Discord, says “passwords are encrypted with SHA-256 so hashcat is Module 20,” and skips MFA. What is hashing vs encryption here, and what do you do?

Multiple choice

Knowledge Check

2

APPLY: True or False: Hashing a file encrypts it, and the SHA-256 hex is the key you use to decrypt — so hashcat against /etc/shadow is ethical CEH homework.

True or False

Knowledge Check

3

APPLY: You are filling hash-vs-encrypt-notes.txt. Which pairing matches the allowed artifact and hygiene?

Multiple choice

Knowledge Check

4

APPLY: curl of http://192.168.0.1/ shows a home router login (TP-Link / Netgear / Huawei / "Router Admin"). Is that DEMO in scope as a hacking target?

Multiple choice

← Previous

Answer all 4 knowledge checks to continue. (0/4 answered)