Skip to content
  • Password Security · Cryptography

Password Security

LearnViaNotes @learnvianotes· 2 min read

Protecting password databases: salts (preventing rainbow tables), peppers, and key stretching ciphers.

1. Why Simple Hashes Fail for Passwords

2. Salt vs. Pepper

3. Key Stretching Algorithms

Using slow, memory-hard algorithms to resist brute-force attacks.

4. Code Implementation: Hashing with bcrypt

A standard implementation using Node.js to hash and verify passwords securely.

JavaScript
const bcrypt = require('bcrypt');

// Hash a password
async function hashPassword(password) {
  const saltRounds = 12; // Cost factor (2^12 rounds)
  const hash = await bcrypt.hash(password, saltRounds);
  return hash;
}

// Verify a password match
async function verifyPassword(password, storedHash) {
  const match = await bcrypt.compare(password, storedHash);
  return match;
}

Free for students and teachers

Write notes like this one

Cards for every idea, quizzes and flashcards, read aloud — on the web and your phone.

Something wrong with this note? Open it to report