Support for hashing algorithms other than SHA1 and MD5
Signed-off-by: Daniel Morris <daniel@honestempire.com>
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index 8ffd93a..3b04f7b 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -484,7 +484,7 @@
*/
public function set_hash($type = 'sha1')
{
- $this->_hash_type = ($type !== 'sha1' && $type !== 'md5') ? 'sha1' : $type;
+ $this->_hash_type = (in_array($type, hash_algos())) ? $type : 'sha1';
}
// --------------------------------------------------------------------
@@ -497,7 +497,7 @@
*/
public function hash($str)
{
- return ($this->_hash_type === 'sha1') ? sha1($str) : md5($str);
+ return hash($this->_hash_type, $str);
}
}