crypto Basics: Hashing vs Encryption
On this page
Cryptographic Primitives
The crypto module provides secure hashing and encryption utilities. Never implement custom cryptographic algorithms.
import { createHash } from 'crypto';
const hash = createHash('sha256')
.update('password')
.digest('hex');
Password Handling
Use strong hashing algorithms with salting. For authentication systems, prefer battle-tested libraries built on top of crypto.
Data Integrity
Hashes verify file integrity, sign payloads, and secure tokens in distributed systems.
Security Insight
Cryptographic misuse is a security vulnerability. Always follow modern security guidelines.