Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- /**
- * Hash Helper
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Hash Helper
- * @author Kader Bouyakoub <bkader@mail.com>
- * @link @KaderBouyakoub
- *
- */
- if ( ! function_exists('generate_salt'))
- {
- /**
- * Generate a random SALT
- *
- * @access public
- * @param integer
- * @return string
- */
- function generate_salt($length = 8)
- {
- if ($length > 32) $length = 32;
- return substr(md5(microtime()), 0, $length);
- }
- }
- if ( ! function_exists('hash_password'))
- {
- /**
- * Hash a password
- *
- * @access public
- * @param string
- * @param string
- * @return string
- */
- function hash_password($password, $salt)
- {
- // Make sure you use your own method and
- // KEEP IT SECRET ;)
- return md5(md5($salt.':'.md5($password)));
- }
- }
- if ( ! function_exists('check_password'))
- {
- /**
- * Compare between two password
- *
- * @access public
- * @param string
- * @param string
- * @param string
- * @return boolean
- */
- function check_password($password, $salt, $hashed)
- {
- $_hased = hash_password($password, $salt);
- return $_hased === $hashed;
- }
- }
- /* End of file hash_helper.php */
- /* Location: ./application/helpers/hash_helper.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement