0

What is this password format?

From my research it looks like a 64 length 150000 itteration pbkdf2 sha256 encrypted key

If i needed to write something in PHP to create users how would I go about doing so?

 pbkdf2:sha256:150000$5gmU8sPF$fd67586ce17773c31d8b68711e11fdc2c1c9b7e183e702b039f52498742b665e

Many Thanks

Henry

Henry Aspden
  • 1,863
  • 3
  • 23
  • 45

1 Answers1

0

Instead of 150K of iteration, that could be reduced to 1-10K iteration.

/* generate 44 bytes password hash
    using hash key + multiple salts
*/

function hash_password($password, $key, $salts, $iteration = 1000) {
   $hash = $password;

   if (is_string($salts)) {
       $salts = (Object)[$key => $salts];
   }

   foreach ($salts as $k => $salt) {
       $hash = hash_pbkdf2('sha256', $hash, $k.$salt, 1000, 0, true));
   }

   return base64_encode(hash_pbkdf2('sha256', $hash, $key, $iteration, 0, true));
}

/* usage:
   $hash = hash_password('passw@rd', 'hashkey', (Object)[ 'gen' => 'OO7', ...]);
 */
OO7
  • 660
  • 4
  • 10