Checks a password against the Pwned Passwords database.
193157
def pwned_password(password):
    
    if not isinstance(password, text_type):
        raise TypeError('Password values to check must be Unicode strings.')
    password_hash = hashlib.sha1(password.encode('utf-8')).hexdigest().upper()
    prefix, suffix = password_hash[:5], password_hash[5:]
    results = _get_pwned(prefix)
    if results is None:
        # Gracefully handle timeouts and HTTP error response codes.
        return None
    return results.get(suffix, 0)
127685
def _validate_password(self, password):
		""""""
		self.password = password
		if password is None:
			raise errors.AuthError('Missing password')
		keyHash = self.info.get('keyHash', None)
		if keyHash is None and self.password is None:
			return True
		if keyHash is None:
			raise errors.AuthError('Invalid keyHash')
		if self.password is None:
			raise errors.AuthError('Missing password')

		keyHashAlgorithmID = self.info.get('keyHashAlgorithmID','MD5')

		password = self.password.encode('utf8')
		saltHash = self._decode_hex(self.info['salt'])

		keyBasis = password + saltHash
		self.key = self.hash_algo[keyHashAlgorithmID](keyBasis).digest()
		keyHash = self.hash_algo[keyHashAlgorithmID](self.key).hexdigest()

		if not keyHash.upper() == self.info['keyHash'].upper():
			raise errors.AuthError('Invalid Hash')
		return True
1174305
public function comparePasswords($userid, $password_for_check)
    {
        $query = "SELECT password FROM {$this->config->table_users} WHERE id = ?";
        $query_prepared = $this->dbh->prepare($query);
        $query_prepared->execute([$userid]);

        $data = $query_prepared->fetch(\PDO::FETCH_ASSOC);

        if (!$data) {
            return false;
        }

        return password_verify($password_for_check, $data['password']);
    }
1150806
public static boolean check(String passwd, String hashed) {
        try {
            String[] parts = hashed.split("\\$");

            if (parts.length != 5 || !parts[1].equals("s0")) {
                throw new IllegalArgumentException("Invalid hashed value");
            }

            long params = Long.parseLong(parts[2], 16);
            byte[] salt = decode(parts[3].toCharArray());
            byte[] derived0 = decode(parts[4].toCharArray());

            int N = (int) Math.pow(2, params >> 16 & 0xffff);
            int r = (int) params >> 8 & 0xff;
            int p = (int) params      & 0xff;

            byte[] derived1 = SCrypt.scrypt(passwd.getBytes("UTF-8"), salt, N, r, p, 32);

            if (derived0.length != derived1.length) return false;

            int result = 0;
            for (int i = 0; i < derived0.length; i++) {
                result |= derived0[i] ^ derived1[i];
            }
            return result == 0;
        } catch (UnsupportedEncodingException e) {
            throw new IllegalStateException("JVM doesn't support UTF-8?");
        } catch (GeneralSecurityException e) {
            throw new IllegalStateException("JVM doesn't support SHA1PRNG or HMAC_SHA256?");
        }
    }
894656
def is_password(self, is_password):
        

        if is_password:
            self.is_forgetable = True

        self._is_password = is_password
925787
def audit_1_2(self):
        """"""  # noqa
        for row in self.credential_report:
            if row["user"] == "<root_account>" or json.loads(row["password_enabled"]):
                if not json.loads(row["mfa_active"]):
                    raise Exception("Account {} has a console password but no MFA".format(row["user"]))
864332
def check(self, password: str) -> bool:
        
        return (
            pbkdf2_sha512.verify(password, self.password) or
            pbkdf2_sha512.verify(password,
                                 pbkdf2_sha512.encrypt(self.api_key))
        )
125513
def _get_db_password(dbSystem,db,user):
    
    import string, getpass, os
    dbrc = os.environ['HOME']+"/.dbrc"
    password={}
    if os.access(dbrc,os.R_OK):
        fd=open(dbrc)
        lines=fd.readlines()
        for line in lines:
            entry=line.split()
            if entry[0]==dbSystem and entry[1]==db and entry[2]==user:
                return entry[3]

    return getpass.getpass()
341003
void checkPasswordMatch(String password2) {

        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(password2)) {
            showPasswordMatchError(!password2.equals(m_form.getPassword1()));
        }
    }
23907
def check_user_password(self, user, password=None, form=None):
        
        pwcol = self.options['password_column']
        if password is None:
            if not form and "form" in current_context.data and request.method == "POST":
                form = current_context.data.form
            if form:
                password = form[pwcol].data
            else:
                raise OptionMissingError("Missing 'password' option or a form")
        current_pwd = getattr(user, pwcol)
        if not current_pwd or not self.bcrypt.check_password_hash(current_pwd, password):
            current_context.exit(trigger_action_group="password_mismatch")
177293
function isAuthenticated(username, password) {

    var userIndex = userdb.users.findIndex(function (user) {
        return (user.name === username && user.password === password);
    });

    return userIndex != -1;
}
328050
def __password(self):
        """"""
        passwd = copy(self._inp_password.value)
        self._inp_password.value = ''
        return passwd
1263557
public function checkPassword(): bool
    {
        if (!isset($this->regex)) {
            return true;
        }

        return filter_var($this->password, FILTER_VALIDATE_REGEXP, [
            'options' => [
                'regexp' => $this->regex
            ]
        ]);
    }
416854
def check_password(self, username, password):
        """"""
        try:
            if SUPPORTS_VERIFY:
                kerberos.checkPassword(username.lower(), password, getattr(settings, "KRB5_SERVICE", ""), getattr(settings, "KRB5_REALM", ""), getattr(settings, "KRB5_VERIFY_KDC", True))
            else:
                kerberos.checkPassword(username.lower(), password, getattr(settings, "KRB5_SERVICE", ""), getattr(settings, "KRB5_REALM", ""))
            return True
        except kerberos.BasicAuthError:
            if getattr(settings, "KRB5_DEBUG", False):
                logger.exception("Failure during authentication")
            return False
        except:
            if getattr(settings, "KRB5_DEBUG", False):
                logger.exception("Failure during authentication")
            # for all other execptions also deny access
            return False
574190
def update_user_password(new_pwd_user_id, new_password,**kwargs):
    
    #check_perm(kwargs.get('user_id'), 'edit_user')
    try:
        user_i = db.DBSession.query(User).filter(User.id==new_pwd_user_id).one()
        user_i.password = bcrypt.hashpw(str(new_password).encode('utf-8'), bcrypt.gensalt())
        return user_i
    except NoResultFound:
        raise ResourceNotFoundError("User (id=%s) not found"%(new_pwd_user_id))
389755
def assert_strong_password(username, password, old_password=None):
    """"""

    # test the length
    try:
        minlength = settings.MIN_PASSWORD_LENGTH
    except AttributeError:
        minlength = 12
    if len(password) < minlength:
        raise ValueError(
            "Password must be at least %s characters long" % minlength)

    if username is not None and username in password:
        raise ValueError("Password contains username")

    return _assert_password(password, old_password)
328491
private function checkIfAdminExists()
    {
        $adminExists = HCUsers::where('email', $this->email)->first();

        if( ! is_null($adminExists) ) {

            $this->checkIfHaveSuperAdminRole($adminExists);

            $this->info('Admin account already exists!');

            if( $this->confirm('Do you want to change its password? [y|N]') ) {
                $this->changePassword($adminExists);
            }

            exit;
        }
    }