Advertisement
METAJIJI

Untitled

Apr 1st, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. /**
  2. * Return encoded password by specified encode type
  3. * La2::PassEncode()
  4. *
  5. * @param mixed $pass
  6. * @param string $type
  7. * @return
  8. */
  9. public function PassEncode($pass, $type='sha1')
  10. {
  11. if ($type == 'whirlpool')
  12. return base64_encode(hash('whirlpool', $pass, true));
  13. else
  14. return base64_encode(pack('H*', sha1(utf8_encode($pass))));
  15. }
  16.  
  17. /**
  18. * Usage:
  19. * $encode_type is 'whirlpool' or 'sha1'
  20. */
  21. $new_pass = '123'; $encode_type = 'sha1'; $encode_type = 'whirlpool';
  22. echo PassEncode($new_pass, $encode_type);
  23.  
  24. /**
  25. * For check
  26. * password: 123
  27. * SHA1: QL0AFWMIX8NRZTKeof9cXsvbvu8=
  28. * whirpool: NEkH6JuYHK8iHQX1l+tXpq9AjxX03XiVu9G5aik47CSn3PI6y5Ts4LbXsGQDWLxWvbRIGUuTBTEa/wOKg0oHnw==
  29. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement