Skip to content

text.hash

fingerprints of text: SHA and MD5 hashes, HMAC signatures, CRC-32 checksums

Fingerprints of text. A hash turns any text into a short fixed-length value, shown as hex. The same input always gives the same hash, and the smallest change gives a completely different one, so hashes are used to check that data hasn’t changed.

SHA-256 and SHA-512 are secure. MD5 and SHA-1 are broken for security purposes but still fine as checksums, and CRC-32 only catches accidental damage.

Tags: crypto

  • sha1 the SHA-1 hash, in hex
  • sha256 the SHA-256 hash, in hex
  • sha512 the SHA-512 hash, in hex
  • md5 the MD5 hash, in hex
  • hmac the HMAC of s with the secret key, in hex
  • hash_id what kind of hash this looks like, from its length and format, likeliest first
  • hash_match the candidate whose hash is this one, or nil, hashing each with every algorithm hash_id suggests that zil has
  • crc32 the CRC-32 checksum, as an integer, the same one zip files and PNG images use
sha1(s: str) -> str

the SHA-1 hash, in hex

1
"hello".sha1"aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
Example outputCtrl+Enter to run

See also sha256

sha256(s: str) -> str

the SHA-256 hash, in hex

1
"hello".sha256[..16]"2cf24dba5fb0a30e"
Example outputCtrl+Enter to run

See also md5, hmac

sha512(s: str) -> str

the SHA-512 hash, in hex

1
"hello".sha512[..16]"9b71d224bd62f378"
Example outputCtrl+Enter to run

See also sha256

md5(s: str) -> str

the MD5 hash, in hex

1
"hello".md5"5d41402abc4b2a76b9719d911017c592"
Example outputCtrl+Enter to run

See also sha256

hmac(s: str, key: str, alg: str = “sha256”) -> str

the HMAC of s with the secret key, in hex

A hash mixed with the key, so only someone with the key can produce it, which is how APIs sign messages and webhooks. alg is the hash to use: “sha256”, “sha1”, “sha384”, “sha512” or “md5”

1
hmac("msg", "secret")"fe4f9c418f683f034f6af90d1dd5b86ac0355dd96332c59cc74598d0736107f6"
2
hmac("msg", "secret", "sha1")"ca3efb15cfaf530e0d771e5cbe707104f006b257"
Example outputCtrl+Enter to run

See also sha256

hash_id(hash: str) -> list

what kind of hash this looks like, from its length and format, likeliest first

Hex digests are told apart only by length, so 32 hex digits could be MD5, NTLM or MD4. Crypt-style hashes like $2b$… (bcrypt) and $6$… (SHA-512 crypt) are recognized by their prefix. Empty when nothing fits

1
hash_id("5d41402abc4b2a76b9719d911017c592")["md5", "ntlm", "md4"]
2
hash_id("$2b$12$abcdefghijklmnopqrstuuJ2WBHnL3eYDKZJ6XtAlr3yXlJ9z8u2G")["bcrypt"]
Example outputCtrl+Enter to run

See also hash_match, md5

hash_match(hash: str, candidates: list) -> str|nil

the candidate whose hash is this one, or nil, hashing each with every algorithm hash_id suggests that zil has

Works for MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hex digests, upper or lower case. A small dictionary attack, for when a puzzle hands you a hash and a word list

1
hash_match("5d41402abc4b2a76b9719d911017c592", ["hi", "hello", "hey"])"hello"
Example outputCtrl+Enter to run

See also hash_id, md5, sha256

crc32(v: str|list|bytes) -> int

the CRC-32 checksum, as an integer, the same one zip files and PNG images use

1
"hello".crc32907060870
2
"hello".crc32 to hex0x3610a686
Example outputCtrl+Enter to run

See also sha256, md5

1
# the MD5 hash of hello
2
"hello".md5"5d41402abc4b2a76b9719d911017c592"
3
# a CRC-32 checksum in hex
4
"hello".crc32 to hex0x3610a686
5
# sign a message with a secret key
6
hmac("msg", "secret")"fe4f9c418f683f034f6af90d1dd5b86ac0355dd96332c59cc74598d0736107f6"
Example outputCtrl+Enter to run

Example results generated on 2026-11-04. Ones using now, today or randomness will differ when you run them.