self::MAXLENGTH) { return self::ERROR_TOOBIG; } if (!preg_match(self::VALIDCHARACTERREGEX, $password)) { return self::ERROR_INVALID; } return false; } /** * Checks that the password and password confirmation fields match * * @param string $confirmation The password confirmation entered * @param string $password The original passord entered * @return int|boolean On error, a "ERROR_" constant indicating the type of error. False if the username passes validation. */ public static function checkPasswordConfirmation($confirmation, $password) { if (mb_strlen($confirmation, 'UTF-8') === 0) { return self::ERROR_MISSING; } if ($confirmation !== $password) { return self::ERROR_MISMATCH; } return false; } /****************************************************************************** * Utility Functions ******************************************************************************/ /** * Applies encryption to the password * * @param string $password */ private static function encrypt($password) { return md5($password); } }