/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * CodeIgniter Extended Encryption Class * * An extension to CI's encryption class to provide a lot more hash algorithms. PHP * 5.1.2+ is highly recommended to take full advantage of this class, however extra * user made hash functions can be used as if they are added to the * 'MY_Encrypt::_custom_hashes' array. * * @package CodeIgniter * @subpackage Extended libraries * @category Extended libraries * @author Jeffy * @link */ class MY_Encrypt extends CI_Encrypt { // Built-in CodeIgniter hash algorithms 'sha1', 'md5', ); // Custom hash algorithms ); function MY_Encrypt() { parent::CI_Encrypt(); } function set_hash($type = 'sha1') { if ($this->hash_exists($type)) { $this->_hash_type = $type; } } { if ($this->hash_exists($this->_hash_type)) { // CodeIgniter built-in hashes { // Hash algorithms available using the PHP5 'hash' function // Hash algorithms available using the PHP5 'openssl_digest' function } elseif (function_exists('openssl_digest') AND in_array($this->_hash_type, @openssl_get_md_methods())) { return openssl_digest($str, $this->_hash_type); // Custom hash functions/algorithms referenced by the $_custom_hashes array { } } } else { // Default to SHA1 instead of MD5. $this->_hash_type = 'sha1'; } } function hash_exists($type) { return ( ); } } ?>