Interview › Security & DevSecOps
Why do you hash and salt passwords rather than encrypt them? [Advanced]
Answer
Passwords are hashed and salted rather than encrypted because applications should not need to recover the original password. A salt makes identical passwords produce different hashes and slows precomputed/rainbow-table attacks; adaptive hashing slows brute-force attempts.
Technical explanation
If encrypted passwords are stolen along with the key, attackers can recover every password.
A unique salt per password prevents attackers from attacking many identical hashes at once.
Use password-hashing algorithms designed to be slow and tunable, not fast general-purpose hashes alone.
Hands-on example
Hands-on: when a user registers, generate a random salt and store bcrypt/Argon2id hash plus parameters. On login, hash the submitted password with the stored parameters and compare using constant-time comparison. Never log or decrypt passwords.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Security & DevSecOps interview questions
- What is the difference between encoding, encryption, and hashing? [Advanced]
- How do you prevent privilege escalation in a Kubernetes cluster? [Advanced]
- What are Kubernetes Pod Security Standards (privileged, baseline, restricted)? [Advanced]
- What are Linux capabilities, and why drop them in containers? [Advanced]
- What is the difference between a WAF, an IDS, and an IPS? [Advanced]
- What is the difference between authentication and authorization? [Advanced]
- What is certificate management, and how do tools like cert-manager help? [Advanced]
- How do you prove to an auditor that security controls are enforced continuously, not just documented? [Advanced]