Announcement

Collapse
No announcement yet.

How is salt created?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How is salt created?

    Would someone please tell me how salt (the kind that is added to passwords) is created?

  • #2
    To create the salt they first have a for() loop which will run until the desired length. In that loop, they add onto a string ($salt). What they add on is a mixture of two functions: rand() and chr():

    PHP Code:
    chr(rand()); 
    First the run rand, with the minimum being the lowest character number (on the ASCII table) they want, with the maximum being the biggest. So, that is 32 and 126. Then the chr() function looks up the character number in the ASCII table and returns the letter.

    If you want to see exactly how it is done, open up ./includes/functions_user and look for fetch_user_salt.
    Bugdar: PHP bug tracking software that is beautiful, fast, and robust.

    Comment


    • #3
      Originally posted by daemon
      To create the salt they first have a for() loop which will run until the desired length. In that loop, they add onto a string ($salt). What they add on is a mixture of two functions: rand() and chr():

      PHP Code:
      chr(rand()); 
      First the run rand, with the minimum being the lowest character number (on the ASCII table) they want, with the maximum being the biggest. So, that is 32 and 126. Then the chr() function looks up the character number in the ASCII table and returns the letter.

      If you want to see exactly how it is done, open up ./includes/functions_user and look for fetch_user_salt.
      Thanks.

      Comment


      • #4
        PHP Code:

        function fetch_user_salt($length 3)
        {
            
        $salt '';
            for (
        $i 0$i $length$i++)
            {
                
        $salt .= chr(rand(33126));
            }
            return 
        $salt;

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...
        X