Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Return encoded password by specified encode type
- * La2::PassEncode()
- *
- * @param mixed $pass
- * @param string $type
- * @return
- */
- public function PassEncode($pass, $type='sha1')
- {
- if ($type == 'whirlpool')
- return base64_encode(hash('whirlpool', $pass, true));
- else
- return base64_encode(pack('H*', sha1(utf8_encode($pass))));
- }
- /**
- * Usage:
- * $encode_type is 'whirlpool' or 'sha1'
- */
- $new_pass = '123'; $encode_type = 'sha1'; $encode_type = 'whirlpool';
- echo PassEncode($new_pass, $encode_type);
- /**
- * For check
- * password: 123
- * SHA1: QL0AFWMIX8NRZTKeof9cXsvbvu8=
- * whirpool: NEkH6JuYHK8iHQX1l+tXpq9AjxX03XiVu9G5aik47CSn3PI6y5Ts4LbXsGQDWLxWvbRIGUuTBTEa/wOKg0oHnw==
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement