Compute a SHA-2 family digest—SHA-256 or SHA-512—from text using the Web Crypto SubtleCrypto API. SHA-2 remains the mainstream choice for integrity checks, HMAC constructions, and modern certificate fingerprints when a collision-resistant hash is required.
Algorithm
You select SHA256 (256-bit / 64 hex chars) or SHA512 (512-bit / 128 hex chars). The browser encodes the input as UTF-8 bytes and runs crypto.subtle.digest with the matching algorithm name. Output is lowercase hex. SHA-512 uses a 64-bit word size internally and is often faster on 64-bit CPUs despite the longer digest.
When to use it
- Checksums for releases, config blobs, or API payload integrity demos
- Comparing SHA-256 vs SHA-512 output length for the same message
- Replacing MD5/SHA-1 fingerprints in documentation with a current algorithm
Limitations
Hashing is not encryption: anyone can recompute the digest. Do not store passwords with raw SHA-2—use a password KDF (Argon2, scrypt, bcrypt). Web Crypto availability and performance depend on the browser environment. Extremely large in-memory strings may hit browser limits.
Example
Hello under SHA-256 yields 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969. The same string under SHA-512 yields 3615f80c9d293ed7402687f94b22d58e529b8cc7916f8fac7fddf7fbd5af4cf777d3d795a7a00a16bf7e7f3fb9561ee9baae480da9fe7a18769e71886b03f315.