Beispiel #1
0
 public static function encrpytPassword($pwd, $salt)
 {
     $check_password = hash('sha256', $pwd . $salt);
     for ($round = 0; $round < getHashKey(); $round++) {
         $check_password = hash('sha256', $check_password . $salt);
     }
     return $check_password;
 }
Beispiel #2
0
 public function resetPassword($new_password)
 {
     $hash_key = getHashKey();
     $db = getDatabase();
     $salt = dechex(mt_rand(0, 2147483647)) . dechex(mt_rand(0, 2147483647));
     $new_encrypted_password = Utils::encrpytPassword($new_password, $salt);
     $q = "UPDATE account_list SET " . self::KEY_ENCRPYPED_PASSWORD . "='{$new_encrypted_password}' , " . self::KEY_SALT . "='{$salt}' WHERE " . self::KEY_ID . "=:id LIMIT 1";
     $params = array(":id" => $this->data[self::KEY_ID]);
     try {
         $stmt = $db->prepare($q);
         $stmt->execute($params);
     } catch (PDOException $ex) {
         Utils::HandlePDOException($ex);
     }
 }