tags:

views:

74

answers:

3

When creating a password with sha1pass, the first value from the token, is '4'.

For instance:

sha1pass test

gives us:

$4$GTdnmykS$25iwV+ruXRwor4pUmKF57uXHj70$

The token uses $ as separators: 25iwV+ruXRwor4pUmKF57uXHj70 is the computed hash, GTdnmykS is the generated salt, since I didn't supply a second parameter, but what does that 4 mean?

The 4 is actually hardcoded, this is the last line of sha1pass, which is a Perl script:

print '$4$', $salt, '$', $pass, "\$\n";

Why is the first value of that token '4', and what does it mean?

+4  A: 

I've seen the convention used where $1$ denotes MD5 and $4$ denotes SHA1. It's hardcoded because it's simply encoding how the hash was generated for future comparison.

Jeff Standen
Thanks, I'll manage from here.
polemon
+5  A: 

It's just a signature so you know what you're looking at is a SHA-1 password; $1$ is used for MD5, $5$ for SHA-2-256, and $6$ for SHA-2-512.

Wooble
+1  A: 

It's a signature telling you the hash type is used, that much is obvious.

Now, why is is present? It's because it's used for unix password hashes, check crypt (Unix):

If the salt begins with the string $digit$ then the Modular Crypt Format is used. The digit represents which algorithm is used in encryption.

snemarch