summaryrefslogtreecommitdiffstats
path: root/system/libraries/Encrypt.php
diff options
context:
space:
mode:
authorJonatas Miguel <jonatas.df.miguel@gmail.com>2012-10-24 19:30:36 +0200
committerJonatas Miguel <jonatas.df.miguel@gmail.com>2012-10-24 19:30:36 +0200
commitb51823dde5fbae508b8ebf99258d2f514a8bece8 (patch)
tree4db09a22f85e0ddf151c940cd3e6fbaa799b8513 /system/libraries/Encrypt.php
parenta53f402b78ad07fb0f6da19cff0c7bec3a09a4c0 (diff)
parenta7001e968a4791312391eb245ad84888893cda8f (diff)
Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into develop
Conflicts: user_guide_src/source/changelog.rst
Diffstat (limited to 'system/libraries/Encrypt.php')
-rw-r--r--system/libraries/Encrypt.php6
1 files changed, 3 insertions, 3 deletions
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index 8ffd93aea..73ab8ca7d 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -165,7 +165,7 @@ class CI_Encrypt {
*/
public function decode($string, $key = '')
{
- if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string))
+ if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string) OR base64_encode(base64_decode($string)) !== $string)
{
return FALSE;
}
@@ -484,7 +484,7 @@ class CI_Encrypt {
*/
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 @@ class CI_Encrypt {
*/
public function hash($str)
{
- return ($this->_hash_type === 'sha1') ? sha1($str) : md5($str);
+ return hash($this->_hash_type, $str);
}
}