SHA-256 hash generator

Get the SHA-256 hash of any text, in hex or Base64, as you type.

loading SHA-256 hash generator
About this tool

What is a SHA-256 hash?

SHA-256 turns any text into a fixed 256-bit fingerprint, written as 64 hexadecimal characters. The same input always gives the same hash, the smallest change gives a completely different one, and there is no way to go back from the hash to the text. That is why it is used to check that a download was not altered, to sign data (TLS certificates, JWTs with HS256 through HMAC), in Git and in blockchains, and to compare values without storing them.

This page opens the hash generator with SHA-256 as the focus. You type or paste text and the SHA-256 digest is computed as you type, in hex, Base64, Base64url or binary. The text is encoded as UTF-8 and hashed in your browser, off the main thread, so even long texts never freeze the page and nothing is sent anywhere. For a legacy checksum, see MD5; to sign a message with a secret key, use the HMAC generator.

How to generate a SHA-256 hash

  1. Type or paste the text into Text to hash.
  2. Read the SHA256 row under Cryptographic hashes. It updates as you type.
  3. Change Digest encoding if the other system expects Base64 instead of hex.
  4. Click the copy button at the end of the row.
  5. To compare with a hash you already have, paste both side by side: hex is case-insensitive, so 2CF2… and 2cf2… are the same value.

Examples

A single word

hello
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

With Digest encoding set to Base64, the same hash reads LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=.

The invisible newline

hello followed by a line break hashes to:

5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03

This is what echo hello | sha256sum prints, because echo adds the newline. If your hash does not match, this is the first thing to check.

The empty string

An empty input always gives e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855. Seeing this value in a log usually means the data you meant to hash never arrived.

Common errors

  • The hash differs from another tool: check trailing spaces and line breaks, and that both sides use UTF-8. Olá in Latin-1 has different bytes than in UTF-8, so a different hash.
  • I need the hash of a file: this tool hashes text. For a file, use sha256sum file or shasum -a 256 file in a terminal.
  • Hashing passwords with plain SHA-256: it is too fast, so leaked hashes are cracked by guessing. Use Argon2id in the password section of the hash generator, or bcrypt.

FAQ

Can a SHA-256 hash be decrypted?

No. Hashing is one-way; there is no key. Sites that "decrypt" SHA-256 only look the hash up in tables of common words, which is why short or common inputs are not protected by hashing alone.

Is SHA-256 still secure?

Yes. No practical collision or preimage attack is known. It is part of the SHA-2 family, and the default in TLS, code signing and most APIs.

What is the difference between SHA-256 and SHA-2?

SHA-2 is the family: SHA-224, SHA-256, SHA-384 and SHA-512. SHA-256 is the member with a 256-bit output.

How to generate SHA-256 in code

JavaScript

const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode('hello'));
[...new Uint8Array(digest)].map(b => b.toString(16).padStart(2, '0')).join('');

Python

import hashlib
hashlib.sha256("hello".encode("utf-8")).hexdigest()

Go

sum := sha256.Sum256([]byte("hello"))
fmt.Println(hex.EncodeToString(sum[:]))

Bash

printf does not add a newline, unlike echo:

printf '%s' hello | sha256sum      # Linux
printf '%s' hello | shasum -a 256  # macOS
Report a problem