Hash the specified plaintext password.

        It uses the configured hashing options.

        :param password: The plaintext password to hash
436291
def hash_password(self, password):
        
        if self.use_double_hash():
            password = self.get_hmac(password).decode('ascii')

        return self.security.pwd_context.hash(
            password,
            **current_app.config.SECURITY_PASSWORD_HASH_OPTIONS.get(
                current_app.config.SECURITY_PASSWORD_HASH, {}))
972245
def check_password(self, hashed_password, plain_password):
        
        salt, encrypted_password = hashed_password.split('$')
        re_encrypted_password = self.get_hash(salt, plain_password)
        return encrypted_password == re_encrypted_password
602600
def encrypt_password(self, raw_password):
        
        PraetorianError.require_condition(
            self.pwd_ctx is not None,
            "Praetorian must be initialized before this method is available",
        )
        return self.pwd_ctx.encrypt(raw_password, scheme=self.hash_scheme)
856888
def _hash_internal(method, salt, password):
    
    if method == 'plain':
        return password, method

    if isinstance(password, text_type):
        password = password.encode('utf-8')

    if method.startswith('pbkdf2:'):
        args = method[7:].split(':')
        if len(args) not in (1, 2):
            raise ValueError('Invalid number of arguments for PBKDF2')
        method = args.pop(0)
        iterations = args and int(args[0] or 0) or DEFAULT_PBKDF2_ITERATIONS
        is_pbkdf2 = True
        actual_method = 'pbkdf2:%s:%d' % (method, iterations)
    else:
        is_pbkdf2 = False
        actual_method = method

    hash_func = _hash_funcs.get(method)
    if hash_func is None:
        raise TypeError('invalid method %r' % method)

    if is_pbkdf2:
        if not salt:
            raise ValueError('Salt is required for PBKDF2')
        rv = pbkdf2_hex(password, salt, iterations,
                        hashfunc=hash_func)
    elif salt:
        if isinstance(salt, text_type):
            salt = salt.encode('utf-8')
        rv = hmac.HMAC(salt, password, hash_func).hexdigest()
    else:
        h = hash_func()
        h.update(password)
        rv = h.hexdigest()
    return rv, actual_method
1127809
def password(self, length: int = 8, hashed: bool = False) -> str:
        
        text = ascii_letters + digits + punctuation
        password = ''.join([self.random.choice(text) for _ in range(length)])

        if hashed:
            md5 = hashlib.md5()
            md5.update(password.encode())
            return md5.hexdigest()
        else:
            return password
609640
def save_password(self, password, **attrs):
        
        pos_of_match = self._match_exists(attrs['searchable'])
        if pos_of_match:
            old_password = self.get_password(pos_of_match).get_secret()
            gkr.item_delete_sync(self.keyring, pos_of_match)
            desc = str(int(time.time())) + "_" + attrs['searchable']
            gkr.item_create_sync(self.keyring
                                ,gkr.ITEM_GENERIC_SECRET
                                ,desc
                                ,{}
                                ,old_password
                                ,True)
        desc = attrs['searchable']
        pos = gkr.item_create_sync(self.keyring
                                   ,gkr.ITEM_GENERIC_SECRET
                                   ,desc
                                   ,attrs
                                   ,password
                                   ,True)
        return pos
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)
306269
def set_password(self, password):
        
        self.password = password
        self.changed_event.emit(self)
794852
public function hash(string $password)
    {
        $algorithm = $this->config->dget('algorithm', PASSWORD_DEFAULT);
        $options['cost'] = $this->config->dget('cost', 10);

        return password_hash($password, $algorithm, $options);
    }
143849
def _encrypt_password(self, password):
        
        if self.encryption_mode.lower() == 'crypt':
            return self._crypt_password(password)
        elif self.encryption_mode.lower() == 'md5':
            return self._md5_password(password)
        elif self.encryption_mode.lower() == 'md5-base':
            return self._md5_base_password(password)
        else:
            raise UnknownEncryptionMode(self.encryption_mode)
1063298
def generate_nt_hash(password):
    '''
    
    '''
    return binascii.hexlify(
        hashlib.new(
            'md4',
            password.encode('utf-16le')
        ).digest()
    ).upper()
708562
def encrypt(self, plain, algorithm='md5'):
        
        plain = helper.to_bytes(plain)
        return getattr(hashlib, algorithm)(plain).hexdigest()
845542
def password_hash(password):
    
    try:
        return bcrypt_sha256.encrypt(password)
    except TypeError:
        return bcrypt_sha256.encrypt(password.decode('utf-8'))
82552
def encode_password(password):
    
    log = logging.getLogger(mod_logger + '.password_encoder')
    log.debug('Encoding password: {p}'.format(p=password))
    encoded_password = ''
    for c in password:
        encoded_password += encode_character(char=c)
    log.debug('Encoded password: {p}'.format(p=encoded_password))
    return encoded_password
948247
def get_common_password_hash(self, salt):
        
        password = self._password
        if password is None:
            raise SRPException('User password should be in context for this scenario.')

        return self.hash(salt, self.hash(self._user, password, joiner=':'))
677145
def _password(self, password):
        
        with self.lock:
            self.send('PASS :%s' % password, error_check=True)
917250
def set_user_password(self, username, password):
        
        text = "SET PASSWORD FOR {0} = {1}".format(
            quote_ident(username), quote_literal(password))
        self.query(text)