daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest May 17th, 2018 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $this->salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36)
  2.    
  3. $s = 'password';
  4. $salt        = 'salt5678901234567890123456789012';
  5. $salt_prefix = 'salt567890123456789010'; // first 21 chars of salt + 0
  6.  
  7. $h1 = password_hash($s, PASSWORD_BCRYPT, array('salt' => $salt));
  8. $h2 = password_hash($s, PASSWORD_BCRYPT, array('salt' => $salt_prefix));
  9.  
  10. echo $h1 . PHP_EOL;
  11. echo $h2 . PHP_EOL;
  12.  
  13. //Result
  14. $2y$10$salt56789012345678901uTWNlUnhu5K/xBrtKYTo7oDy8zMr/csu
  15. $2y$10$salt56789012345678901uTWNlUnhu5K/xBrtKYTo7oDy8zMr/csu
  16.    
  17. $this->salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36)
  18.    
  19. php > var_dump(password_hash('foo', PASSWORD_DEFAULT, ['salt' => str_repeat('a', 22).'b']));
  20. string(60) "$2y$10$aaaaaaaaaaaaaaaaaaaaaO8Q0BjhyjLkn5wwHyGGWhEnrex6ji3Qm"
  21. php > var_dump(password_hash('foo', PASSWORD_DEFAULT, ['salt' => str_repeat('a', 22).'c']));
  22. string(60) "$2y$10$aaaaaaaaaaaaaaaaaaaaaO8Q0BjhyjLkn5wwHyGGWhEnrex6ji3Qm"
  23. php > var_dump(password_hash('foo', PASSWORD_DEFAULT, ['salt' => str_repeat('a', 22).'d']));
  24. string(60) "$2y$10$aaaaaaaaaaaaaaaaaaaaaO8Q0BjhyjLkn5wwHyGGWhEnrex6ji3Qm"
  25.    
  26. base64_encode(  base64_decode($salt) . $actualHashInBinary  )
  27.    
  28. base64_encode(  base64_decode($salt) . $actualHashInBinary  )
RAW Paste Data
Top