Node.js Crypto Module:
π Node.js β Crypto Module
The crypto module provides cryptographic functionality such as:
β Hashing
β Encryption/Decryption
β HMAC
β Random values
β Key generation
Crypto is a built-in module β no installation needed.
β 1. Hashing (MD5, SHA1, SHA256, SHA512)
Hashing is one-way encryption (cannot be reversed).
Example: SHA256 Hash
β 2. HMAC (Hash-based Message Authentication Code)
Used for API security, request signing, etc.
β 3. Generate Random Bytes
Used to generate tokens, OTP, salts, etc.
β 4. Generate Random UUID
β 5. Symmetric Encryption & Decryption (AES)
Uses same key for encryption & decryption.
Example: AES-256 Encryption
β 6. Password Hashing with PBKDF2
Used for secure password storage.
β 7. Key Pair (Public/Private) Generation
Used for RSA, JWT, HTTPS certificates.
β 8. Sign & Verify Data (RSA)
Sign data:
Verify signature:
β 9. Create Secure Hash for Passwords (Salt + Hash)
β 10. Check Supported Ciphers
π― Usage of Crypto in Real Applications
β Password hashing
β JWT / OAuth security
β Token generation
β Encryption of sensitive data
β SSL/HTTPS certificates
β API authentication
β Digital signatures
