3434class Mage_Core_Model_Encryption
3535{
3636 const HASH_VERSION_MD5 = 0 ;
37+ const HASH_VERSION_SHA256 = 1 ;
3738 const HASH_VERSION_SHA512 = 2 ;
3839
3940 /**
@@ -79,7 +80,9 @@ public function getHash($password, $salt = false)
7980 if (is_integer ($ salt )) {
8081 $ salt = $ this ->_helper ->getRandomString ($ salt );
8182 }
82- return $ salt === false ? $ this ->hash ($ password ) : $ this ->hash ($ salt . $ password ) . ': ' . $ salt ;
83+ return $ salt === false
84+ ? $ this ->hash ($ password )
85+ : $ this ->hash ($ salt . $ password , self ::HASH_VERSION_SHA256 ) . ': ' . $ salt ;
8386 }
8487
8588 /**
@@ -110,6 +113,8 @@ public function hash($data, $version = self::HASH_VERSION_MD5)
110113 {
111114 if (self ::HASH_VERSION_LATEST === $ version && $ version === $ this ->_helper ->getVersionHash ($ this )) {
112115 return password_hash ($ data , PASSWORD_DEFAULT );
116+ } elseif (self ::HASH_VERSION_SHA256 == $ version ) {
117+ return hash ('sha256 ' , $ data );
113118 } elseif (self ::HASH_VERSION_SHA512 == $ version ) {
114119 return hash ('sha512 ' , $ data );
115120 }
@@ -128,6 +133,7 @@ public function validateHash($password, $hash)
128133 {
129134 return $ this ->validateHashByVersion ($ password , $ hash , self ::HASH_VERSION_LATEST )
130135 || $ this ->validateHashByVersion ($ password , $ hash , self ::HASH_VERSION_SHA512 )
136+ || $ this ->validateHashByVersion ($ password , $ hash , self ::HASH_VERSION_SHA256 )
131137 || $ this ->validateHashByVersion ($ password , $ hash , self ::HASH_VERSION_MD5 );
132138 }
133139
0 commit comments