Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>function encodePwd($salt, $string) { return sha1( $salt . $string ); } </code></pre> <p>think about salt randomization for a minute though. Password encoding specifically. </p> <p>If i have salt of "random" and a password of "complex", my sha1 would be </p> <pre><code>e55ec45f2873a04d2b888a5f59dd3f9d3bb25329 </code></pre> <p>that's stored in the database. I want to check against that. </p> <p>So when a user supplies me "complex" as a password, i tag "random" in front of it and encode it to get the same hash. If they equal, then bazinga! i'm set. </p> <p>But what if that was random?</p> <p>salt when it was stored: "random"</p> <pre><code>SHA1: e55ec45f2873a04d2b888a5f59dd3f9d3bb25329 </code></pre> <p>salt when the user put it in: "apple"</p> <pre><code>SHA1: e07b207d77a0bd27d321552fc934b186559f9f42 </code></pre> <p>how am i going to match those?</p> <p>If you are looking for a more secure method, use data that you <em>have</em> and that is <em>constant</em> like the username or id of user or something (preferably something that won't change). You need a pattern you can rely on. </p> <p>username would work good (you'd have to make sure to update password if they ever changed the username) that way authentication could look like </p> <pre><code>`WHERE `username` = '&amp;username' AND `password` = '" . encodePwd( $username, $password ) . "'"` function encodePwd( $username, $password) { // maybe modify username on a non-random basis? - like // $username = sha1( substr($username, 2)); // assuming usernames have a min-length requirement return sha1( $username . $password ) ; } </code></pre>
    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. 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