Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>By default htpasswd uses the standard <a href="http://linux.die.net/man/3/crypt" rel="nofollow noreferrer">crypt</a> function and thus passwords are already salted - note in this example that both users have the same password yet the hashes are different:</p> <pre> simon@diablo:~$ htpasswd -b -c htpasswd simon abcd Adding password for user simon simon@diablo:~$ htpasswd -b htpasswd simon2 abcd Adding password for user simon2 simon@diablo:~$ cat htpasswd simon:<b>NWvm/LCCxQ64E</b> simon2:<b>2I.LBzsRqULN6</b> </pre> <p>(note: the <code>-b</code> flag is normally discouraged because other users can see your command line arguments and hence the password)</p> <p>The first two characters of the hash are the salt; passwords are verified by calling <code>crypt()</code> again. Entering the wrong password produces a string that's unequal to the hashed password:</p> <pre><code>&gt;&gt;&gt; from crypt import crypt &gt;&gt;&gt; crypt("wrongpass", "NWvm/LCCxQ64E") 'NWbxQgX1unvso' </code></pre> <p>whereas the correct password produces the expected hash:</p> <pre><code>&gt;&gt;&gt; crypt("abcd", "NWvm/LCCxQ64E") 'NWvm/LCCxQ64E' </code></pre> <p><code>htpasswd -m</code> uses a different algorithm that's MD5-based and uses a longer salt:</p> <pre> simon@diablo:~$ htpasswd -m -b -c htpasswd simon abcd Adding password for user simon simon@diablo:~$ cat htpasswd simon:<b>$apr1$mfvnBVmG$iIHIHOaH9vcImG5G.8eVa/</b> </pre> <p>Here, the salt is the 8 characters between the second and third <code>$</code>.</p> <p><code>htpasswd -s</code> stores a SHA-1 digest with no salt; this appears to be for compatibility with Netscape/LDIF:</p> <pre> simon@diablo:~$ htpasswd -s -b -c htpasswd simon abcd Adding password for user simon simon@diablo:~$ htpasswd -s -b htpasswd simon2 abcd Adding password for user simon2 simon@diablo:~$ cat htpasswd simon:{SHA}gf6L/odXbD7LIkJvjleEc4KRes8= simon2:{SHA}gf6L/odXbD7LIkJvjleEc4KRes8= </pre> <p>These can easily be reversed - convert into a hex digest:</p> <pre><code>&gt;&gt;&gt; "".join("%02x" % ord(c) ... for c in "gf6L/odXbD7LIkJvjleEc4KRes8=".decode("base64")) '81fe8bfe87576c3ecb22426f8e57847382917acf' </code></pre> <p>then use an <a href="http://www.hashkiller.co.uk/sha1-decrypter.aspx" rel="nofollow noreferrer">online hash database</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload