HomeDeveloper & IT › Text Hash Calculator

Text Hash Calculator

Computes the MD5 (RFC 1321), SHA-1 (RFC 3174), SHA-256 (FIPS 180-4) and CRC-32 (IEEE 802.3 polynomial) digests of a text encoded as UTF-8, plus its byte length; all algorithms are implemented in plain JavaScript.

When to use

You need a checksum or digest of a short text to compare with a published value, generate a cache key or verify a test vector.

Do not use when: You need to hash a file or binary data, a keyed MAC (HMAC), a password hash (use bcrypt/scrypt/Argon2), or a hash of more than 200,000 characters.

Formula

digest = H(UTF-8(text)) for H ∈ {MD5, SHA-1, SHA-256}; CRC-32 = reflected CRC with polynomial 0x04C11DB7 (0xEDB88320 reversed), initial value 0xFFFFFFFF, final XOR 0xFFFFFFFF

Reference implementations of RFC 1321, RFC 3174 and FIPS 180-4 on 32-bit words; results match sha256sum / md5sum of the same bytes without a newline. The empty string cannot be submitted (its digests are d41d8cd9…, da39a3ee…, e3b0c442…).

Inputs

ParameterTypeUnitRequiredDescription
textstringyesThe text to hash; it is encoded as UTF-8 without a trailing newline (echo -n).

Outputs

OutputTypeUnitDescription
md5string128-bit MD5 digest, 32 lower-case hex characters (broken for collision resistance; checksums only).
sha1string160-bit SHA-1 digest, 40 hex characters (deprecated for signatures).
sha256string256-bit SHA-256 digest, 64 hex characters.
crc32stringCRC-32 (polynomial 0xEDB88320, as in zlib, PNG and Ethernet), 8 hex characters.
crc32_decimalintegerThe same CRC-32 as an unsigned integer.
byte_lengthintegerbytesLength of the UTF-8 encoding that was hashed.
character_countintegerNumber of Unicode code points in the text.

Example

hello: {"text":"hello"}{"md5":"5d41402abc4b2a76b9719d911017c592","sha1":"aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d","sha256":"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824","crc32":"3610a686","byte_length":5}

The quick brown fox jumps over the lazy dog: {"text":"The quick brown fox jumps over the lazy dog"}{"md5":"9e107d9d372bb6826bd81d3542a419d6","sha1":"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12","sha256":"d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592","crc32":"414fa339","byte_length":43}

GET https://tttkmbb.com/api/v1/calculate/text-hash?text=hello

Machine access

Sources

FAQ

Why does my result differ from echo text | md5sum?

echo appends a newline, so the shell hashes one extra byte. Use echo -n or printf '%s' to hash the bare text.

Which hash should I use?

SHA-256 for integrity and signatures. MD5 and SHA-1 are cryptographically broken (collisions can be manufactured) and CRC-32 detects accidental corruption only.

How are non-ASCII characters handled?

The text is encoded as UTF-8 first, so 'é' contributes 2 bytes and an emoji 4; byte_length reports the encoded size.

Related calculators