TheFileTools

How to generate a SHA-256 hash of text

Compute SHA-1, SHA-256, SHA-384 and SHA-512 of any text in the browser, and why a plain hash is the wrong way to store passwords.

A hash is a fixed-length fingerprint of some data. The same input always gives the same hash, and changing one character gives a completely different one. Developers use hashes to compare values without looking at them, to check that text arrived unchanged and to reproduce what an API or a script computed.

Steps

  1. Open Hash generator.
  2. Type or paste the text.
  3. All four hashes appear at once: SHA-1, SHA-256, SHA-384 and SHA-512. Press Copy next to the one you need.

There is nothing to choose. The text is converted to UTF-8 bytes and hashed by the browser's built-in cryptography, and the result is written in lowercase hexadecimal: 40 characters for SHA-1, 64 for SHA-256, 96 for SHA-384 and 128 for SHA-512. The text does not leave your device.

Worked example

The SHA-256 of the five letters hello is 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824.

Add a line break after the word and the result is 5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03. This is the most common reason two hashes of "the same" text differ: an invisible newline or space at the end, often added by a command-line tool or by copying a whole line. Upper and lower case count as well.

Which algorithm

  • SHA-256 is the usual choice today.
  • SHA-384 and SHA-512 are longer members of the same family.
  • SHA-1 is broken for security purposes, since collisions have been produced in practice. Use it only where an existing system demands it.
  • MD5 is not offered.

What a hash is not

A hash is not encryption, and there is no way to turn it back into the text. Short or common inputs can still be guessed by hashing candidates until one matches. For that reason a plain SHA hash, of any length, is not a safe way to store passwords. Systems that store passwords should use a dedicated slow function such as bcrypt, scrypt or Argon2, with a salt.

To fingerprint a file, for example to verify a download, use File checksum. If you need a random secret and not a fingerprint, use Password generator.