🔐 Encoding Use-Case Recommender – Choose the Right Algorithm
Choosing the wrong encoding, hashing, or encryption scheme is one of the most common sources of security vulnerabilities in modern software. Should you use Base64 or AES-GCM? SHA-256 or bcrypt? RSA or ECDH? This tool acts as an expert guide, asking targeted questions about your data and goals and returning a precise, well-reasoned recommendation — backed by current NIST, OWASP, and RFC standards.
Why Algorithm Choice Matters
The cryptography landscape spans four fundamentally different operations, each solving a different problem:
- Encoding (Base64, URL encoding, Hex) — transforms data into a text-safe or transport-safe format. No security guarantee.
- Hashing (SHA-256, SHA-3, BLAKE2b) — produces a fixed-size one-way fingerprint. Used for integrity verification and digital signatures.
- Password hashing (Argon2id, bcrypt, scrypt) — a specialized subset of hashing that is deliberately slow to resist brute-force attacks.
- Encryption (AES-256-GCM, ChaCha20-Poly1305, RSA-OAEP) — transforms data into ciphertext that only authorised parties can reverse.
Using a fast hash like SHA-256 for password storage is a critical mistake — GPUs can compute billions of SHA-256 hashes per second, making brute-force trivial. Conversely, using bcrypt to verify a file download checksum is unnecessary overhead. The right tool depends on the exact context.
The Seven Core Scenarios
1. Password Storage
Passwords must be hashed with a slow, memory-hard function. The current gold standard is Argon2id (NIST SP 800-63B, OWASP #1 recommendation), followed by bcrypt (cost ≥ 12) andscrypt. Never store passwords with MD5, SHA-1, or plain SHA-256 — they are too fast.
2. Binary-to-Text Transport
When you need to transmit binary data over a text-only protocol (JSON, email, HTML), use Base64. For URLs and JWTs, use Base64 URL-safe (replaces +/ with -_) to avoid percent-encoding. If size overhead matters, consider Base85 (25% overhead vs Base64's 33%).
3. URL Parameter Encoding
For embedding values in query strings, percent-encoding (RFC 3986) is the standard. Use encodeURIComponent() in JavaScript, urllib.parse.quote() in Python. For opaque tokens in URL paths, Base64 URL-safe (without padding) is more compact.
4. Symmetric Encryption (Shared Key)
When both parties share a secret key, AES-256-GCM is the modern standard. It provides authenticated encryption — guaranteeing both confidentiality and integrity in one pass (NIST SP 800-38D). Use a unique 96-bit nonce per operation. ChaCha20-Poly1305 is an excellent alternative on devices without AES hardware acceleration.
5. Asymmetric / Public-Key Encryption
With a public/private key pair, use hybrid encryption: generate a random AES key, encrypt the data with AES-256-GCM, then wrap the AES key withRSA-OAEP (2048-bit+) or ECDH (X25519 / P-256). Never use raw RSA to encrypt large data — it has a 190-byte limit on 2048-bit keys and is vulnerable to chosen-ciphertext attacks without OAEP padding.
6. Integrity Verification (Checksums)
For file checksums and data integrity, SHA-256 is the industry default. For higher-security margins (e.g., code signing, certificate fingerprints), use SHA-3-256 or BLAKE2b. MD5 and SHA-1 are cryptographically broken and should not be used for any security-sensitive integrity check.
7. Identity & Authentication Tokens
For stateless auth tokens, use JWT with RS256 or ES256 (asymmetric signing) so any service can verify without sharing a secret. For single-service setups, JWT HS256 is simpler. For use cases requiring revocability, opaque random tokens stored server-side are preferable. Always use short expiry times and store tokens in httpOnly cookies, not localStorage.
Algorithms You Should Never Use for Security
The following algorithms are either broken or fundamentally unsuitable for security use cases:
- MD5 — Collision attacks demonstrated in 1996. Practical collision in seconds on modern hardware.
- SHA-1 — Deprecated by NIST (2011). SHAttered attack (2017) produced the first practical collision.
- DES / 3DES — DES has a 56-bit key (brute-forced in 22 hours in 1999). NIST deprecated 3DES for all applications after 2023.
- AES-ECB — Deterministic output leaks patterns — identical plaintext blocks produce identical ciphertext.
- RSA PKCS#1 v1.5 padding — Vulnerable to Bleichenbacher's 1998 adaptive chosen-ciphertext attack. Use OAEP.
- Base64 for security — Base64 is encoding, not encryption. It provides zero confidentiality.
How to Read the Recommendations
The recommender classifies every algorithm with one of three labels:
- Primary (Best Match) — The optimal algorithm for your exact input combination, aligned with current best-practice standards.
- Alternative — Suitable options when the primary is unavailable, performance constraints exist, or specific platform support is needed.
- Avoid — Algorithms that are broken, deprecated, or fundamentally unsuitable for the described use case.
Each recommendation comes with a code snippet for Node.js, Python, Java, Go, PHP, or Browser JavaScript — ready to copy directly into your project. The comparison table lets you see all candidates side-by-side across reversibility, security level, speed, and output size overhead.