QA
Beginner LevelWeb Security & Cyber Defense

What are Cryptographic Hash Functions (SHA-256) and their core properties (one-way, collision-resistant)?

❓ Interview Prompt: Explain Cryptographic Hash Functions, SHA-256, determinism, Avalanche Effect, One-Way property (pre-image resistance), and Collision Resistance.

A Cryptographic Hash Function is a mathematical algorithm that maps data of arbitrary size to a fixed-size bit string (e.g. SHA-256 produces a 256-bit / 64-hex-character output):

4 Essential Properties:

1
Deterministic: The same input always produces the exact same hash output.
2
One-Way (Pre-Image Resistance): Computationally infeasible to reverse a hash back to its original input.
3
Avalanche Effect: Changing a single input bit drastically changes the output hash.
4
Collision Resistance: Computationally infeasible to find two different inputs that produce the exact same output hash.

Code Implementation Example

typescript
import crypto from 'crypto';

// SHA-256 Hash Computation
const hash = crypto
  .createHash('sha256')
  .update('Hello World')
  .digest('hex');

console.log(hash); // a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e
💡Computing a SHA-256 cryptographic hash in Node.js.
🎯 Interview Key Takeaway

Cryptographic hash functions are deterministic, one-way, avalanche-sensitive, and collision-resistant.

#Cryptography#SHA-256#Hashing#Beginner
Back to all Web Security & Cyber Defense Questions→

More Web Security & Cyber Defense Interview Questions

Beginner LevelSecurity & Web Security

Explain OWASP Top 10 vulnerabilities (XSS, CSRF, SQL Injection) and their defenses.

Beginner LevelSecurity & Web Security

What are the 3 types of XSS (Stored, Reflected, DOM-based) and how do they differ?

Beginner LevelSecurity & Web Security

How do Parameterized Queries (Prepared Statements) prevent SQL Injection attacks?