33.3 Symmetric Encryption
Symmetric encryption uses one shared key to encrypt and decrypt. It is fast, so it protects bulk data.
- AES (Advanced Encryption Standard) with 128 or 256-bit keys is the standard today. Modes matter: AES-GCM gives encryption plus integrity; avoid ECB mode, which leaks patterns.
- ChaCha20-Poly1305 is a fast modern alternative, common on mobiles.
- Old and unsafe: DES, 3DES, RC4.
echo "Kolhapur shop sales: 4,20,000" > secret.txt
openssl enc -aes-256-cbc -pbkdf2 -salt -in secret.txt -out secret.enc # asks for a passphrase
openssl enc -d -aes-256-cbc -pbkdf2 -in secret.enc -out back.txt
gpg -c secret.txt # symmetric with GPG, creates secret.txt.gpg
The big problem with symmetric crypto is key exchange: how do two people who have never met share the key safely? Asymmetric crypto solves that.
Ravindra Bagale's Tip
Even strong encryption is useless if you keep the key right next to the file – like locking a door and hanging the key on it. Keep keys separate: AWS KMS, Secrets Manager, a password manager. And never build "my own encryption algorithm" – use tested standards (AES).
Ravindra Bagale's Tip – मराठी
Encryption strong असले तरी key file सोबतच ठेवली तर काही उपयोग नाही – जसे कुलूप लावून चावी दरवाज्यावर लटकवली. Keys वेगळ्या ठेवा: AWS KMS, Secrets Manager, password manager. आणि "माझा स्वतःचा encryption algorithm" कधीच बनवू नका – tested standards (AES) वापरा.
Ravindra Bagale's Tip – हिंदी
Encryption strong हो फिर भी key file के साथ ही रखी तो कोई फ़ायदा नहीं – जैसे ताला लगाकर चाबी दरवाज़े पर लटका दी. Keys अलग रखो: AWS KMS, Secrets Manager, password manager. और "अपना खुद का encryption algorithm" कभी मत बनाओ – tested standards (AES) इस्तेमाल करो.
Lab
Encrypt a file with openssl enc -aes-256-cbc -pbkdf2, send the .enc file to a partner in class, and share the passphrase by a different channel (spoken, not in the same message). Ask them to decrypt it. Then try decrypting with a wrong passphrase and note the error.
Extended teaching notes
Why this lesson matters
Part 11 turns tool skills into professional defensive practice: web risks, cloud, SOC work, hardening, cryptography, Indian law and careers. Every example below stays inside systems you own or public teaching material.
Indian company (sample data)
Suppose we are a junior security engineer at an Infosys or TCS client project. You take this lesson's checklist, map it to three production services (for example a Spring Boot API, a Node.js portal and a Python job), and open tickets with evidence and owners.
Global practice
Follow public guidance from OWASP, CERT-In, CISA and cloud provider Well-Architected / security pillars. Cite them in reports.
Everyday analogy
A cricket team that only practises hitting but never fielding loses matches. Offence skills in a lab exist to improve fielding in real systems.
Apply across stacks
Wherever code appears, ask the same questions.
Java / Spring Boot
Parameterise queries, encode output, limit Actuator, patch dependencies.
.NET
EF Core parameters, HTTPS, Data Protection API, patch NuGet.
Node.js
helmet, parameterized SQL, npm audit, lockfiles.
Python
ORM, autoescape, pip-audit, Bandit.
Go / PHP / Ruby
Safe templates, prepared statements, govulncheck / composer audit / Brakeman.
nginx / Apache / Tomcat
Hide versions, TLS, least-open ports.
MySQL / PostgreSQL / MongoDB / Redis
No public ports, auth on, least-privilege users.
AWS / Azure / GCP
Roles not keys, private data stores, cloud logs on.
Defender worksheet
- Write a 5-line summary.
- Name one related public breach or advisory.
- Practise one safe command on a lab you own.
- Write the fix for a teammate.
Recap
- Permission first.
- Fix over spectacle.
- Evidence in notes.
Defender's worksheet (do this today)
- Write the lesson title and date.
- List three owned systems where it applies.
- Run one safe lab check and paste evidence.
- Write a two-sentence fix for a teammate.
- Note one CERT-In or CISA advisory that relates (title + date).
Indian workplace (sample)
At a Wipro or LTIMindtree client SOC, turn this lesson into one playbook step with an owner and a due date.
Global practice
Compare your notes with OWASP, CIS Benchmarks or a cloud Well-Architected security question. Write the overlap in five lines.
Family test
Explain the risk and the fix without jargon. If a parent or sibling can repeat the warning, you are ready to teach juniors.
Common mistakes
- Skipping permission.
- Tool collecting without fixing.
- Publishing lab screenshots that contain secrets.
- Treating encoding as encryption.
Recap
- Evidence, fix, owner, date.
- Own lab only.
Key terms for this page
- Control: a safeguard (patch, config, process).
- Finding: a weakness with evidence.
- Remediation: the fix and how you verified it.
- Scope: systems you are allowed to touch.
- Least privilege: only the access required for the task.
- Defence in depth: several controls in layers.
Mini case study
Suppose we are a junior engineer at Zoho or Freshworks (sample data). A weekly review asks each person to present one control from their area. You pick a control from this lesson, show a before/after screenshot from a lab, and list the production ticket you would open. That habit builds both skill and credibility.