Web Security Fundamentals: Hashing, JWTs, and Certificates

By the BoltQuickTools team | April 9, 2026 | Updated November 8, 2026 | 10 min read

A misconfigured JWT, a missing certificate check, or a weak password hash can expose user data no matter how clean the rest of your code is. This article covers the fundamentals most web developers run into: hashing, password storage, JSON Web Tokens, TLS certificates, SSH keys, and UUIDs.

You do not need to be a cryptographer. You need to know enough to choose the right tool, use it correctly, and notice when something looks wrong.

Cryptographic Hashing: The Foundation

A hash function takes an input of any size and produces a fixed-length output. The same input always produces the same output, but even a single changed character results in a completely different hash. This property makes hashing useful for verifying data integrity, generating checksums, and fingerprinting content.

MD5: Fast but Broken

MD5 produces a 128-bit (32-character hex) hash and was the go-to algorithm for years. However, researchers demonstrated practical collision attacks in 2004, meaning two different inputs can produce the same hash. You should never use MD5 for security purposes. It is still fine for non-security tasks like cache keys or deduplication checksums, but keep it away from anything that protects user data.

SHA-1: Deprecated

SHA-1 produces a 160-bit (40-character) hash. Google and CWI Amsterdam demonstrated a practical collision in 2017 (the SHAttered attack), and browsers no longer trust SHA-1 certificates. Do not use it in new security work. You will still see it in legacy systems and in Git, which defaults to SHA-1 object IDs in most repositories.

SHA-256: The Current Standard

SHA-256 is part of the SHA-2 family and produces a 256-bit (64-character) hash. It remains the standard recommendation for most security applications: file integrity verification, digital signatures, and certificate fingerprints. When a software publisher posts a checksum alongside a download, it is almost always SHA-256.

You can try generating hashes for your own text or files with the Hash Generator. It computes MD5, SHA-1, SHA-256, and SHA-512 simultaneously so you can compare the output lengths and formats side by side.

# Verify a downloaded file on the command line
sha256sum ubuntu-24.04-desktop-amd64.iso
# Compare the output against the published checksum

Password Hashing: A Different Problem

General-purpose hash functions like SHA-256 are designed to be fast. That is a problem for password storage, because an attacker with a leaked database can try billions of SHA-256 guesses per second on a modern GPU. Password hashing algorithms solve this by being deliberately slow.

bcrypt, Argon2, and PBKDF2

bcrypt dates to 1999. It has a configurable cost factor and embeds a random salt in its output. It only processes the first 72 bytes of a password, so set a matching length limit.

Argon2 won the 2015 Password Hashing Competition. It lets you tune time, memory, and parallelism, and its memory cost makes GPU and ASIC attacks more expensive. For a new project, use Argon2id.

PBKDF2 applies an HMAC many times, with OWASP recommending 600,000 iterations for HMAC-SHA-256. It is widely available in standard libraries and is the usual choice where FIPS-140 compliance is required. It is not memory-hard, so GPUs have more of an advantage against it. See Hashing Passwords in 2026 for parameters.

// Node.js example: hashing a password with bcrypt
const bcrypt = require('bcrypt');
const saltRounds = 12;

// Hashing
const hash = await bcrypt.hash('user-password', saltRounds);

// Verifying
const match = await bcrypt.compare('user-password', hash);
console.log(match); // true

Need to generate strong passwords for testing? The Password Generator creates cryptographically random passwords with configurable length and character sets.

JWTs: Authentication Tokens Explained

JSON Web Tokens are a common way to carry authentication claims between services. A JWT is a compact, URL-safe string made of three Base64URL-encoded parts separated by dots: header.payload.signature.

The Three Parts

The header specifies the algorithm (like HS256 or RS256) and the token type. The payload contains claims: data like user ID, roles, expiration time, and issuer. The signature is created by signing the encoded header and payload with a secret key (symmetric) or private key (asymmetric).

// JWT structure (decoded)
// Header
{ "alg": "HS256", "typ": "JWT" }

// Payload
{
  "sub": "user-12345",
  "name": "Alice",
  "role": "admin",
  "iat": 1712620800,
  "exp": 1712624400
}

// Signature
HMACSHA256(
  base64UrlEncode(header) + "." + base64UrlEncode(payload),
  secret
)

How Verification Works

When a server receives a JWT, it re-computes the signature using the encoded header and payload plus its own copy of the secret. If the computed signature matches the one in the token, the token has not been tampered with. For asymmetric algorithms (RS256), the server uses the public key to verify the signature made with the private key.

Common JWT Mistakes

You can inspect and decode any JWT with the JWT Decoder. It splits the token into its three parts, decodes the header and payload, and shows the signature.

SSL/TLS Certificates: Securing Data in Transit

When you visit a site over HTTPS, your browser and the server perform a TLS handshake that authenticates the server and sets up an encrypted channel. Knowing the steps helps when you debug certificate errors.

How HTTPS Works

In TLS 1.3, the client and server exchange ephemeral key shares (usually elliptic-curve Diffie-Hellman) and derive the session keys from them. The server then proves its identity by presenting its certificate and signing the handshake with the matching private key. The client verifies the certificate against a chain of trust leading to a trusted Certificate Authority (CA). The certificate's key authenticates the server but does not encrypt the traffic, so a stolen key cannot decrypt recordings of past sessions.

Certificate Chains

A certificate chain typically has three levels: the root CA (trusted by the operating system or browser), an intermediate CA (signed by the root), and the end-entity certificate (signed by the intermediate). Servers should send the intermediates along with their own certificate. An expired or invalid link fails validation, and a missing intermediate breaks some clients even when browsers manage to work around it.

SANs and Expiration

Subject Alternative Names (SANs) specify which domains a certificate covers. A single certificate might cover example.com, www.example.com, and api.example.com. A wildcard certificate for *.example.com matches one label only, so it does not cover a.b.example.com or the bare domain unless that is listed too.

Certificate lifetimes are getting shorter. Under CA/Browser Forum rules, the maximum for public TLS certificates dropped to 200 days in March 2026, goes to 100 days in March 2027, and to 47 days in March 2029. Let's Encrypt certificates are currently valid for 90 days by default, with 64 days scheduled from February 2027 and 45 days by 2028. Automate renewal and monitor expiry. To inspect a certificate's chain, SANs, and expiration date, paste it into the SSL Certificate Decoder.

SSH Keys: Secure Remote Access

SSH keys use public-key cryptography to authenticate you to remote servers without passwords. You generate a key pair: the private key stays on your machine, and the public key goes on the server. When you connect, the server challenges you to prove you hold the private key, and your SSH client responds without ever sending the key itself.

RSA vs ECDSA vs Ed25519

RSA is the oldest and most widely supported. A 3072-bit or 4096-bit key provides strong security, but the keys are large and generation is slower.

ECDSA uses elliptic curve cryptography, producing shorter keys with equivalent security. A 256-bit ECDSA key provides roughly the same security as a 3072-bit RSA key. However, ECDSA has a subtle vulnerability: if the random number generator used during signing is weak, the private key can be recovered.

Ed25519 is a good default. It uses an Edwards curve, is fast, produces compact keys, and derives its signing nonce deterministically, which avoids the random number failure that affects ECDSA. Unless you need compatibility with very old systems, use it for new keys.

# Generate an Ed25519 SSH key pair
ssh-keygen -t ed25519 -C "[email protected]"

# The public key goes on the server
cat ~/.ssh/id_ed25519.pub

# The private key stays on your machine (never share it)
# ~/.ssh/id_ed25519

The SSH Key Generator creates RSA and ECDSA key pairs in your browser using the Web Crypto API. It does not offer Ed25519, so use ssh-keygen as shown above for that.

UUID Generation: Unique Identifiers Done Right

UUIDs (Universally Unique Identifiers) are 128-bit values used as primary keys, request IDs, and correlation tokens. Two versions are worth knowing about.

UUID v4: Random

UUID v4 is generated from random bytes and has no inherent ordering, so a database index on v4 values takes inserts at scattered positions across its pages. It is a good fit when you need a unique identifier and ordering does not matter.

UUID v7: Time-Sorted

UUID v7 (standardized in RFC 9562 in 2024) puts a millisecond Unix timestamp in the most significant bits, followed by random data, so values sort roughly by creation time. That usually helps B-tree index performance on large tables. The trade-off is that anyone who can see the ID can read when it was created, so think before exposing it in URLs. Neither version should be used as a secret. UUID v7 for new databases goes into detail.

// UUID v4 example (random)
// 550e8400-e29b-41d4-a716-446655440000

// UUID v7 example (time-sorted)
// 018ef4c8-5a3b-7000-8000-1a2b3c4d5e6f
// the first 48 bits (018ef4c8-5a3b) are the timestamp

// In JavaScript (crypto API)
const uuid = crypto.randomUUID(); // Generates v4

Generate both versions instantly with the UUID Generator.

Practical Security Checklist

Here is a condensed checklist you can reference when building or reviewing a web application:

  1. Password storage: Use Argon2id or bcrypt. Never SHA-256 or MD5.
  2. File integrity: Use SHA-256 checksums. Publish them alongside downloads.
  3. JWTs: If kept in cookies, use HttpOnly and SameSite with CSRF protection. Enforce the signing algorithm on the server. Always set and validate expiration.
  4. HTTPS: Use TLS 1.2 or 1.3. Redirect HTTP to HTTPS. Enable HSTS.
  5. Certificates: Automate renewal, since lifetimes are shrinking. Monitor expiration dates. Serve the full chain.
  6. SSH: Use Ed25519 keys. Disable password authentication on servers. Rotate keys periodically.
  7. UUIDs: Consider v7 for database primary keys, and do not expose it where the creation time is sensitive. Use a dedicated random token for secrets.
  8. Secrets: Never commit API keys to version control. Use environment variables or a secrets manager.
  9. Dependencies: Run npm audit or equivalent regularly. Pin dependency versions.
  10. Headers: Set Content-Security-Policy (including frame-ancestors, which supersedes X-Frame-Options in current browsers), X-Content-Type-Options, and Strict-Transport-Security.

Wrapping Up

Most of these come down to decisions made during development: which hash to use, where to store tokens, how certificates are renewed, and which key type to generate. They do not need deep cryptographic expertise, but they do need attention.

To see these concepts in practice, try hashing some text, decoding a JWT, or inspecting a certificate.