# Salts And Hashes

**URL:** <https://boards.straightdope.com/t/salts-and-hashes/321579>\
**Category:** Factual Questions\
**Created:** [September 14, 2005, 12:01pm UTC](https://boards.straightdope.com/t/salts-and-hashes/321579 "2005-09-14T12:01:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![treebug](https://avatars.discourse-cdn.com/v4/letter/t/85f322/32.png) [@treebug](https://boards.straightdope.com/u/treebug)\
**Post date:** [September 14, 2005, 12:01pm UTC](https://boards.straightdope.com/t/salts-and-hashes/321579/1 "2005-09-14T12:01:32Z")

</div>

I understand what a password’s HASH value is. Could someone explain what a SALT is?

thx

---

<div class="post-metadata">

**Author:** ![ftg](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ftg/32/2801_2.png) [@ftg](https://boards.straightdope.com/u/ftg)\
**Post date:** [September 14, 2005, 1:11pm UTC](https://boards.straightdope.com/t/salts-and-hashes/321579/2 "2005-09-14T13:11:52Z")

</div>

A salt is a quasi-random starter string to “mix” with the password to get the hash value:

E.g., HashFunction(Password, Salt) = HashedPassword.

Certain salts are better than others in giving a more random-like distribution. But note that the salt has to be kept around and should be assumed to be known to any password cracker.

---

<div class="post-metadata">

**Author:** ![iamthewalrus\_3](https://avatars.discourse-cdn.com/v4/letter/i/258eb7/32.png) [@iamthewalrus\_3](https://boards.straightdope.com/u/iamthewalrus_3)\
**Post date:** [September 14, 2005, 4:49pm UTC](https://boards.straightdope.com/t/salts-and-hashes/321579/3 "2005-09-14T16:49:37Z")

</div>

The **purpose** of a salt is that someone attempting to do a dictionary attack on the stored passwords will have to build a set of hashes for the dictionary _with your salt_. If you didn’t have the salt, then the hashes could have been calculated once long ago and stored.

---

<div class="post-metadata">

**Author:** ![Absolute](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Absolute](https://boards.straightdope.com/u/Absolute)\
**Post date:** [September 14, 2005, 5:33pm UTC](https://boards.straightdope.com/t/salts-and-hashes/321579/4 "2005-09-14T17:33:17Z")

</div>

I believe the default password implementation on many Linux systems uses salts.

The passwords are stored with a random, two-character salt first, followed by the hash of the password with the salt prepended.

For example: let’s say the password is “widget”. When recording the password, the system generates a salt, say “GH”. It then hashes the string “GHwidget”, getting “AF443” (which I just made up, obviously that would be a rather weak algorithm).

The password is then stored as GHAF443. To verify a password, the system extracts the salt, prepends it to the password, and computes the hash to see if it matches.

As mentioned, this means that dictionary attacks can’t be used against the password database, because they would need to be recalculated for whatever salt was used.

---

<div class="post-metadata">

**Author:** ![SlyFrog](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@SlyFrog](https://boards.straightdope.com/u/SlyFrog)\
**Post date:** [September 14, 2005, 5:41pm UTC](https://boards.straightdope.com/t/salts-and-hashes/321579/5 "2005-09-14T17:41:07Z")

</div>

I really entered into this thread presuming we would be talking about corned beef hash and saltiness. 🙂
