Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Whirlpool hash, jak to skonfigurować?
Benoc
post 19.05.2018, 12:40:04
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 19.05.2018

Ostrzeżenie: (0%)
-----


Cześć,
Mam pytanie odnośnie konfiguracji Whirlpool na forum, nigdzie nic nie mogę o tym znaleźć, a chcę zastąpić md5 whirlpoolem bo jest po prostu lepszy smile.gif

Dodaje kod md5:
  1. function salt_password($password, $salt)
  2. {
  3. return md5(md5($salt).$password);
  4. }


  1. function create_password($password, $salt = false, $user = false)
  2. {
  3. global $plugins;
  4.  
  5. $fields = null;
  6.  
  7. $parameters = compact('password', 'salt', 'user', 'fields');
  8.  
  9. if(!defined('IN_INSTALL') && !defined('IN_UPGRADE'))
  10. {
  11. $plugins->run_hooks('create_password', $parameters);
  12. }
  13.  
  14. if(!is_null($parameters['fields']))
  15. {
  16. $fields = $parameters['fields'];
  17. }
  18. else
  19. {
  20. if(!$salt)
  21. {
  22. $salt = generate_salt();
  23. }
  24.  
  25. $hash = md5(md5($salt).md5($password));
  26.  
  27. $fields = array(
  28. 'salt' => $salt,
  29. 'password' => $hash,
  30. );
  31. }
  32.  
  33. return $fields;
  34. }



  1. function verify_user_password($user, $password)
  2. {
  3. global $plugins;
  4.  
  5. $result = null;
  6.  
  7. $parameters = compact('user', 'password', 'result');
  8.  
  9. if(!defined('IN_INSTALL') && !defined('IN_UPGRADE'))
  10. {
  11. $plugins->run_hooks('verify_user_password', $parameters);
  12. }
  13.  
  14. if(!is_null($parameters['result']))
  15. {
  16. return $parameters['result'];
  17. }
  18. else
  19. {
  20. $password_fields = create_password($password, $user['salt'], $user);
  21.  
  22. return my_hash_equals($user['password'], $password_fields['password']);
  23. }
  24. }


Jakby ktoś potrzebował cały kod: https://pastebin.com/gFjwVk8t

Z góry dziękuje za pomoc smile.gif
Pozdrawiam

Go to the top of the page
+Quote Post
viking
post 19.05.2018, 13:13:00
Post #2





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Poczytaj lepiej o password_hash.


--------------------
Go to the top of the page
+Quote Post
Benoc
post 26.05.2018, 13:44:24
Post #3





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 19.05.2018

Ostrzeżenie: (0%)
-----


Cytat(viking @ 19.05.2018, 14:13:00 ) *
Poczytaj lepiej o password_hash.


Zamieniłem na to:
  1. function salt_password($password, $salt)
  2. {
  3. return hash('whirlpool', $salt . $checkPass);
  4. }


oraz na to:

  1. function create_password($password, $salt = false, $user = false)
  2. {
  3. global $plugins;
  4.  
  5. $fields = null;
  6.  
  7. $parameters = compact('password', 'salt', 'user', 'fields');
  8.  
  9. if(!defined('IN_INSTALL') && !defined('IN_UPGRADE'))
  10. {
  11. $plugins->run_hooks('create_password', $parameters);
  12. }
  13.  
  14. if(!is_null($parameters['fields']))
  15. {
  16. $fields = $parameters['fields'];
  17. }
  18. else
  19. {
  20. if(!$salt)
  21. {
  22. $salt = generate_salt();
  23. }
  24.  
  25. $hash = hash('whirlpool', $salt . $checkPass);
  26.  
  27. $fields = array(
  28. 'salt' => $salt,
  29. 'password' => $hash,
  30. );
  31. }
  32.  
  33. return $fields;
  34. }



Ale dalej coś nie działa tongue.gif

Prosiłbym o dalszą pomoc.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 16.04.2024 - 23:47