Hash generator · Guide

SHA256 Generator With Salt: When Salting Helps and When It Does Not

Salting SHA-256 defeats precomputed lookup tables and hides repeated inputs. It does not make SHA-256 a password hash, and confusing those two outcomes is a common and costly mistake.

What the salt buys you

A salt is a unique random value stored next to each digest and mixed into the input. Two identical inputs then produce different digests, so nobody can tell from the table that two users share a password.

It also makes rainbow tables useless: an attacker would need a separate precomputed table per salt, which is not worth building.

What it does not buy you

Time. SHA-256 is fast by design, and consumer GPUs compute billions of salted SHA-256 hashes per second. Against a stolen database an attacker brute-forces each salt independently and gets through weak passwords quickly.

Password storage needs a slow, memory-hard function — Argon2id, scrypt, bcrypt. They handle salting internally, so you never write the salting code yourself, which is where most implementations introduce bugs.

Where salted SHA-256 fits

Anonymised identifiers: hashing an email with a per-dataset salt lets you join records without storing the address, while making cross-dataset correlation harder.

Cache and shard keys that must not collide across tenants. Deterministic pseudonyms in analytics. Anywhere the digest being guessed is inconvenient rather than dangerous.

If you need a keyed digest rather than a salted one — where the secret must stay server-side — use HMAC-SHA256, not concatenation. Hashing a secret prefix directly is vulnerable to length extension.

Generating the salt

Use a cryptographic random source and at least 16 bytes. A counter, a username or a timestamp is not a salt — it is predictable, which removes the only guarantee a salt provides:

PHP
$salt = random_bytes(16);                    // PHP
salt = os.urandom(16)                        # Python
const salt = crypto.getRandomValues(new Uint8Array(16)); // JS

Frequently asked questions

Does the salt need to be secret?

No. Salts are stored alongside the hash. A secret mixed in is called a pepper and serves a different purpose.

Is salted SHA-256 acceptable for passwords?

No. It is far too fast. Use Argon2id or bcrypt.

How long should a salt be?

16 random bytes is the common recommendation and is plenty.

Ready to try it?

Open the free browser-based Hash generator and apply what you just read — no sign-up, runs locally.

Open the Hash generator tool