Magento 1.9.x 暴力换密码

   遇到丢掉密码的情况,其实很常见……比如我这记性,还好我比较暴力:-P

   先看一段代码:

   

/**
 * Hash a string
 *
 * @param string $data
 * @return string
 */
public function hash($data)
{
    return md5($data);
}

/**
 * Validate hash against hashing method (with or without salt)
 *
 * @param string $password
 * @param string $hash
 * @return bool
 * @throws Exception
 */
public function validateHash($password, $hash)
{
    $hashArr = explode(':', $hash);
    switch (count($hashArr)) {
        case 1:
            return $this->hash($password) === $hash;
        case 2:
            return $this->hash($hashArr[1] . $password) === $hashArr[0];
    }
    Mage::throwException('Invalid hash.');
}


 

看到这里,我们立马可以知道,原来magento的密码算法其实很简单;

  密码存储格式:  pass:hash  ,magento会拿  

  公式: pass= md5( hash + Password )

  于是得到最终 数据库字段值:   md5( hash + Password ) :  hash

  至此,暴力完成 :-P

你可能感兴趣的:(Magento 1.9.x 暴力换密码)