reads the password defined in the Lucee configuration, this can also in older formats (only
hashed or encrypted)

@param el
@param salt
@param isDefault
@return
505975
public static Password readFromXML(Element el, String salt, boolean isDefault) {
	String prefix = isDefault ? "default-" : "";

	// first we look for the hashed and salted password
	String pw = el.getAttribute(prefix + "hspw");
	if (!StringUtil.isEmpty(pw, true)) {
	    // password is only of use when there is a salt as well
	    if (salt == null) return null;
	    return new PasswordImpl(ORIGIN_HASHED_SALTED, pw, salt, HASHED_SALTED);
	}

	// fall back to password that is hashed but not salted
	pw = el.getAttribute(prefix + "pw");
	if (!StringUtil.isEmpty(pw, true)) {
	    return new PasswordImpl(ORIGIN_HASHED, pw, null, HASHED);
	}

	// fall back to encrypted password
	String pwEnc = el.getAttribute(prefix + "password");
	if (!StringUtil.isEmpty(pwEnc, true)) {
	    String rawPassword = new BlowfishEasy("tpwisgh").decryptString(pwEnc);
	    return new PasswordImpl(ORIGIN_ENCRYPTED, rawPassword, salt);
	}
	return null;
    }
1361902
@SuppressFBWarnings(value = "DM_DEFAULT_ENCODING", justification = "Open TODO item for wider rework")
    @Override
    protected void eol(byte[] bytes, int len) throws IOException {
        String line = new String(bytes, 0, len);
        if(passwordsAsPattern != null) {
            line = passwordsAsPattern.matcher(line).replaceAll(MASKED_PASSWORD);
        }
        logger.write(line.getBytes());
    }
164490
public EncryptionKey generateAndSaveKeyProtectedByPassword(String password) {
        EncryptionKey dpk = null;
        if (password == null || password.equals("")) {
            throw new IllegalArgumentException("password is required to be a non-null/non-empty " +
                    "string");
        }
        try {
            if (!keyExists()) {
                byte[] dpkBytes = generateSecureRandomBytesWithLength
                        (ENCRYPTION_KEYCHAIN_ENCRYPTIONKEY_SIZE);
                byte[] salt = generateSecureRandomBytesWithLength
                        (ENCRYPTION_KEYCHAIN_PBKDF2_SALT_SIZE);
                byte[] iv = generateSecureRandomBytesWithLength
                        (ENCRYPTIONKEYCHAINMANAGER_AES_IV_SIZE);
                SecretKey aesKey = pbkdf2DerivedKeyForPassword(password, salt,
                        ENCRYPTION_KEYCHAIN_PBKDF2_ITERATIONS,
                        ENCRYPTION_KEYCHAIN_AES_KEY_SIZE);

                byte[] encryptedDpkBytes = DPKEncryptionUtil.encryptAES(aesKey, iv, dpkBytes);

                KeyData keyData = new KeyData(encryptedDpkBytes, salt, iv,
                        ENCRYPTION_KEYCHAIN_PBKDF2_ITERATIONS, ENCRYPTION_KEYCHAIN_VERSION);

                if (this.storage.saveEncryptionKeyData(keyData)) {
                    dpk = new EncryptionKey(dpkBytes);
                }
            }
        } catch (InvalidKeyException e) {
            throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
        } catch (NoSuchPaddingException e) {
            throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
        } catch (NoSuchAlgorithmException e) {
            throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
        } catch (IllegalBlockSizeException e) {
            throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
        } catch (BadPaddingException e) {
            throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
        } catch (InvalidAlgorithmParameterException e) {
            throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
        } catch (InvalidKeySpecException e) {
            throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
        }
        return dpk;
    }
507459
function (password, algorithm, salt) {
            salt = salt || Crypto.randomBytes(128).toString("hex");
            algorithm = algorithm || this.$.algorithm;

            var hash = Crypto.createHash(this.$.algorithm);
            hash.update(salt + password, "utf8");

            return [algorithm, salt, hash.digest("hex")].join(this.$.delimiter);
        }
1149071
public String encriptPassword(String password)
    {
        String newpassword = null;
        byte[] defaultBytes = password.getBytes();
        try
        {
            MessageDigest algorithm = MessageDigest.getInstance("MD5");
            algorithm.reset();
            algorithm.update(defaultBytes);
            byte messageDigest[] = algorithm.digest();

            StringBuffer hexString = new StringBuffer();
            for (int i = 0; i < messageDigest.length; i++)
            {
                hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
            }
            newpassword = hexString.toString();
        }
        catch (NoSuchAlgorithmException e)
        {
            log.error("Error while encripting password {}, caused by : .", password, e);
            throw new PersistenceException(e);
        }
        return newpassword;
    }
1056295
public static function getHashedPasswordWithSalt($password) {
		
		// salt for bcrypt needs to be 22 base64 characters (only [./0-9A-Za-z])
		$salt = substr(str_replace('+', '.', base64_encode(sha1(microtime(true), true))), 0, 22);
		
		// 2a = bcrypt algorithm selector, 12 = the workload factor
		$hash = crypt($password, '$2a$12$' . $salt);
		
		return $hash;

	}
997566
public function getPassword(): ?PasswordBroker
    {
        if (!$this->hasPassword()) {
            $this->setPassword($this->getDefaultPassword());
        }
        return $this->password;
    }
463832
protected void initPasswordDigest() {
    if(saltGenerator == null) {
      saltGenerator = new Default16ByteSaltGenerator();
    }
    if (passwordEncryptor == null) {
      passwordEncryptor = new Sha512HashDigest();
    }
    if(customPasswordChecker == null) {
      customPasswordChecker = Collections.emptyList();
    }
    if(passwordManager == null) {
      passwordManager = new PasswordManager(passwordEncryptor, customPasswordChecker);
    }
  }
989179
public static String encrypt(String salt, String password, String plainText) {
        SecretKey secret = getKey(salt, password);
        return encryptBouncyCastle(secret, plainText);
    }
838835
public function generatePasswordHash(string $password, string $salt = ''): string
    {
        $password = ($salt ?: self::$salt) . trim($password);

        $options = [
            'cost' => 12,
        ];

        return password_hash($password, PASSWORD_BCRYPT, $options);
    }
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=':'))
203911
public function getSolrPassword($defaultIfEmpty = '', $scope = 'read')
    {
        $scopePath = 'plugin.tx_solr.solr.' . $scope . '.password';
        $fallbackPath = 'plugin.tx_solr.solr.password';

        return $this->getValueByPathWithFallbackOrDefaultValueAndApplyStdWrap($scopePath, $fallbackPath, $defaultIfEmpty);
    }
628153
private byte[] pbkdf2(char[] password, byte[] salt) {
        try {
            PBEKeySpec spec = new PBEKeySpec(password, salt, PBKDF2_ITERATIONS, HASH_BYTE_SIZE * 8);
            SecretKeyFactory skf = SecretKeyFactory.getInstance(PBKDF2_ALGORITHM);
            return skf.generateSecret(spec).getEncoded();
        } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
            throw SeedException.wrap(e, CryptoErrorCode.UNEXPECTED_EXCEPTION);
        }
    }
1323698
function (password, algorithm, salt) {

            return {
                hash: this.createHash(password, algorithm, salt),
                loginAttempts: 0,
                loginBlocked: null
            }

        }
570031
function encryptPassword(password, callback) {
        bcrypt.gen_salt(workFactor, function(err, salt) {
            if (err) callback(err);
            
            bcrypt.encrypt(password, salt, function(err, hashedPassword) {
                if (err) callback(err);
                
                callback(null, hashedPassword);
            });
        });
    }
294038
def kdf_salt(self):
        

        encryption_algo = self['algorithm'].native

        if encryption_algo == 'pbes2':
            salt = self['parameters']['key_derivation_func']['parameters']['salt']

            if salt.name == 'other_source':
                raise ValueError(unwrap(
                    '''
                    Can not determine key derivation salt - the
                    reserved-for-future-use other source salt choice was
                    specified in the PBKDF2 params structure
                    '''
                ))

            return salt.native

        if encryption_algo.find('.') == -1:
            if encryption_algo.find('_') != -1:
                return self['parameters']['salt'].native

            raise ValueError(unwrap(
                '''
                Encryption algorithm "%s" does not have a registered key
                derivation function
                ''',
                encryption_algo
            ))

        raise ValueError(unwrap(
            '''
            Unrecognized encryption algorithm "%s", can not determine key
            derivation salt
            ''',
            encryption_algo
        ))
1052088
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

    if is_pbkdf2:
        if not salt:
            raise ValueError("Salt is required for PBKDF2")
        rv = pbkdf2_hex(password, salt, iterations, hashfunc=method)
    elif salt:
        if isinstance(salt, text_type):
            salt = salt.encode("utf-8")
        mac = _create_mac(salt, password, method)
        rv = mac.hexdigest()
    else:
        rv = hashlib.new(method, password).hexdigest()
    return rv, actual_method