Reference
Web Crypto API Reference
Web Crypto API algorithms, limits and safety notes for browser tools.
Overview
The Web Crypto API provides browser-native cryptographic primitives for hashing, key generation and encryption demos. It is useful for local developer tools, but production security still depends on key management, algorithm choice, random IVs and careful handling of secrets.
Debugging Reference Table
| Feature | Supported use | Debugging and safety note |
|---|---|---|
| crypto.subtle.digest("SHA-256") | Generate SHA-256 digests | Useful for checksums and examples, not encryption. |
| crypto.subtle.digest("SHA-1") | Generate SHA-1 digests | Legacy compatibility only; avoid for security-sensitive workflows. |
| MD5 | Not supported by Web Crypto | Do not use MD5 for password storage or modern security. |
| AES-GCM | Authenticated symmetric encryption | Requires unique IV per key and safe key handling. |
| getRandomValues | Cryptographically strong random bytes | Use for IVs and nonces, not Math.random(). |
| importKey | Load raw or structured key material | A password is not the same as a cryptographic key. |
| deriveKey | Derive keys from passwords | Use a proper KDF such as PBKDF2 when password-based keys are needed. |
| extractable: false | Prevent key export | Helpful for reducing accidental key exposure in browser code. |
Reference Table Coverage
- Browser-native hashing.
- AES-GCM demo encryption.
- Random IV generation.
- Why MD5 is omitted from modern browser crypto.
API Debugging Examples
- Generate a SHA-256 checksum for copied text.
- Encrypt a demo message locally with AES-GCM.
- Explain why an AES payload cannot be decrypted without IV and key metadata.
Common Mistakes
- Treating hashes as encrypted data.
- Reusing an AES-GCM IV with the same key.
- Using Math.random for cryptographic values.
- Pasting production secrets into a browser demo.
FAQ
Why does the hash tool not generate real MD5 with Web Crypto?
Web Crypto does not support MD5, and MD5 is not suitable for modern security-sensitive workflows.
Is browser encryption automatically safe?
No. The algorithm may be strong, but key management, IV uniqueness and data handling still determine safety.
What is AES-GCM good for?
AES-GCM provides authenticated encryption when used with a safe key and unique IV.