Hashes the password using pbkdf2 and the given salt.

@param password the plain text password to hash.
@param salt the salt for the password
@return the hashed password
485668
public char[] hash(char[] password, byte[] salt) {
    checkNotNull(password);
    checkArgument(password.length != 0);
    checkNotNull(salt);
    checkArgument(salt.length != 0);

    try {
      SecretKeyFactory f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
      SecretKey key =
          f.generateSecret(new PBEKeySpec(password, salt, ITERATIONS, DESIRED_KEY_LENGTH));
      return Base64.encodeBase64String(key.getEncoded()).toCharArray();
    } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
      throw new IllegalStateException("Could not hash the password of the user.", e);
    }
  }
441305
public static String[] encrypt(String password) {
        SecureRandom random = new SecureRandom();
        String salt = new BigInteger(130, random).toString(32);
        String encryptPassword = encrypt(password, salt);
        return new String[] {encryptPassword, salt};
    }
32527
function hashpw(password, salt, callback, progress) {
    var real_salt;
    var passwordb = [];
    var saltb = [];
    var hashed = [];
    var minor = String.fromCharCode(0);
    var rounds = 0;
    var off = 0;

    if (!progress) {
        progress = function() {};
    }

    if (salt.charAt(0) != '$' || salt.charAt(1) != '2')
        throw "Invalid salt version";
    if (salt.charAt(2) == '$')
        off = 3;
    else {
        minor = salt.charAt(2);
        if ((minor != 'a' && minor != 'b') || salt.charAt(3) != '$')
            throw "Invalid salt revision";
        off = 4;
    }

    // Extract number of rounds
    if (salt.charAt(off + 2) > '$')
        throw "Missing salt rounds";
    var r1 = parseInt(salt.substring(off, off + 1)) * 10;
    var r2 = parseInt(salt.substring(off + 1, off + 2));
    rounds = r1 + r2;
    real_salt = salt.substring(off + 3, off + 25);
    password = password + (minor >= 'a' ? "\000" : "");
    passwordb = password_to_bytes(password)
    saltb = decode_base64(real_salt, BCRYPT_SALT_LEN);
    crypt_raw(
        passwordb,
        saltb,
        rounds,
        BF_CRYPT_CIPHERTEXT.slice(0),
        function(hashed) {
            var rs = [];
            rs.push("$2");
            if (minor >= 'a')
                rs.push(minor);
            rs.push("$");
            if (rounds < 10)
                rs.push("0");
            rs.push(rounds.toString());
            rs.push("$");
            rs.push(encode_base64(saltb, saltb.length));
            rs.push(encode_base64(hashed, BF_CRYPT_CIPHERTEXT.length * 4 - 1));
            callback(rs.join(''));
        },
        progress);
}
8695
public static byte[] encryptBytes (PublicKey key, byte[] secret, byte[] salt)
    {
        byte[] encrypt = new byte[secret.length + salt.length];
        for (int ii = 0; ii < secret.length; ii++) {
            encrypt[ii] = secret[ii];
        }
        for (int ii = 0; ii < salt.length; ii++) {
            encrypt[secret.length + ii] = salt[ii];
        }
        try {
            return getRSACipher(key).doFinal(encrypt);
        } catch (GeneralSecurityException gse) {
            log.warning("Failed to encrypt bytes", gse);
        }
        return encrypt;
    }
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
        ))
1191821
public static String createHash(char[] password) throws NoSuchAlgorithmException, InvalidKeySpecException {

    final SecureRandom random = new SecureRandom();
    final byte[] salt = new byte[SALT_BYTES];
    random.nextBytes(salt);

    final byte[] hash = pbkdf2(password, salt, PBKDF2_ITERATIONS, HASH_BYTES);
    // format iterations:salt:hash
    return PBKDF2_ITERATIONS + ":" + toHex(salt) + ":" + toHex(hash);
  }
221226
public function encode( $password, $salt = null )
	{
		return ( isset( $this->hasher ) ? $this->hasher->getHashedPassword( $password, $salt ) : $password );
	}
198135
function encrypt(salt, password) {
    var hash = crypto.createHash('sha256').update(salt + password).digest('base64');
    return salt + hash;
}
1201753
public function verifyPasswordHash(string $password, string $hash, string $salt = ''): string
    {
        $password = ($salt ?: self::$salt) . trim($password);

        return password_verify($password, $hash);
    }
1374079
public String deriveKeyFormatted(String inputPassword) {
		PBKDF2Parameters p = getParameters();
		byte[] salt = generateSalt();
		p.setSalt(salt);
		p.setDerivedKey(deriveKey(inputPassword));
		String formatted = getFormatter().toString(p);
		return formatted;
	}
1216976
function (user, password, salt) {
  var inner = md5(password + user)
  var outer = md5(Buffer.concat([Buffer.from(inner), salt]))
  return 'md5' + outer
}
1275908
public static function cryptVerify($password, $hash)
    {
        $salt = substr($hash, 0, 2);
        try {
            // PHP 7 throws exception for invalid salt
            $actual = crypt($password, $salt);
        } catch (\Exception $e) {
            return false;
        }
        return ($actual === $hash);
    }
1203716
public static String createPassword(String password) {

        String data = DigestUtils.shaHex(password);
        return data;
    }
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;
    }
989179
public static String encrypt(String salt, String password, String plainText) {
        SecretKey secret = getKey(salt, password);
        return encryptBouncyCastle(secret, plainText);
    }
560380
public static String getCryptoAlgorithm(String password) {
        if (null == password) {
            return null;
        }
        String algorithm = null;
        String data = password.trim();

        if (data.length() >= 2) {
            if ('{' == data.charAt(0)) {
                int end = data.indexOf('}', 1);
                if (end > 0) {
                    algorithm = data.substring(1, end).trim();
                }
            }
        }

        return algorithm;
    }
434787
public static String md5(String data, String salt) {
        return bytes2HexString(md5ToByte((data + salt).getBytes()));
    }