{@inheritDoc} The password salt must be of type {@link PasswordSaltBCrypt}.
189707
@Nonnull
  public String createPasswordHash (@Nonnull final IPasswordSalt aSalt, @Nonnull final String sPlainTextPassword)
  {
    ValueEnforcer.notNull (aSalt, "Salt");
    ValueEnforcer.isInstanceOf (aSalt, PasswordSaltBCrypt.class, "Salt");
    ValueEnforcer.notNull (sPlainTextPassword, "PlainTextPassword");

    return BCrypt.hashpw (sPlainTextPassword, aSalt.getSaltString ());
  }
1315132
private function encodePassword(UserInterface $user, $password, $salt)
    {
        $encoder = $this->get('sulu_security.encoder_factory')->getEncoder($user);

        return $encoder->encodePassword($password, $salt);
    }
841367
static int execute(Arg arguments, PrintStream stream, PrintStream errorStream) {
        if (arguments == null) {
            return 2;
        }

        if (arguments.checkBcryptHash != null) { // verify mode
            BCrypt.Result result = BCrypt.verifyer().verify(arguments.password, arguments.checkBcryptHash);
            if (!result.validFormat) {
                System.err.println("Invalid bcrypt format.");
                return 3;
            }

            if (result.verified) {
                stream.println("Hash verified.");
            } else {
                errorStream.println("Provided hash does not verify against given password.");
                return 1;
            }
        } else { // hash mode
            byte[] salt = arguments.salt == null ? Bytes.random(16).array() : arguments.salt;
            byte[] hash = BCrypt.withDefaults().hash(arguments.costFactor, salt, charArrayToByteArray(arguments.password, StandardCharsets.UTF_8));
            stream.println(new String(hash, StandardCharsets.UTF_8));
        }
        return 0;
    }
455843
public static String getHash(final String password, final String salt) {

		if (StringUtils.isEmpty(salt)) {

			return getSimpleHash(password);

		}

		return DigestUtils.sha512Hex(DigestUtils.sha512Hex(password).concat(salt));

	}
1273556
private function validateSaltLength(string $salt)
    {
        if (\mb_strlen($salt, '8bit') !== self::KEY_SALT_BYTE_LENGTH) {
            throw new InvalidArgumentException('Salt must be ' . self::KEY_SALT_BYTE_LENGTH . ' bytes long');
        }
    }
628652
public static boolean validatePassword(char[] password, String goodHash) throws NoSuchAlgorithmException, InvalidKeySpecException {

    final String[] params = goodHash.split(":");
    final int iterations = Integer.parseInt(params[ITERATION_INDEX]);
    final byte[] salt = fromHex(params[SALT_INDEX]);
    final byte[] hash = fromHex(params[PBKDF2_INDEX]);
    // Compute the hash of the provided password, using the same salt,
    // iteration count, and hash length
    final byte[] testHash = pbkdf2(password, salt, iterations, hash.length);
    // Compare the hashes in constant time. The password is correct if
    // both hashes match.
    return slowEquals(hash, testHash);
  }
621769
@Override
    public boolean verify(@Sensitive char[] password, String hashedPassword) {
        String[] items = parseData(hashedPassword);
        byte[] originalHash = Base64Coder.base64DecodeString(items[3]);
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "original Hash length : " + (originalHash != null?originalHash.length:"null"));
        }
        if (originalHash == null) {
            String message = Tr.formatMessage(tc, "JAVAEESEC_CDI_ERROR_PASSWORDHASH_INVALID_DATA", Tr.formatMessage(tc, "JAVAEESEC_CDI_INVALID_HASH_VALUE"));
            Tr.error(tc, message);
            throw new IllegalArgumentException(message);
        }
        byte[] salt = Base64Coder.base64DecodeString(items[2]);
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "original Salt length : " + (salt != null?salt.length:"null"));
        }
        if (salt == null) {
            String message = Tr.formatMessage(tc, "JAVAEESEC_CDI_ERROR_PASSWORDHASH_INVALID_DATA", Tr.formatMessage(tc, "JAVAEESEC_CDI_INVALID_SALT_VALUE"));
            Tr.error(tc, message);
            throw new IllegalArgumentException(message);
        }
        byte[] calculatedHash = generate(items[0], Integer.parseInt(items[1]), originalHash.length, salt, password);
        return Arrays.equals(originalHash, calculatedHash);
    }
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);
        }
    }
925345
public function resaltPassword($password, $salt = '')
		{

			// No salt used..?
			$auth = self::$auth;
			if ($auth->useSalt == false) {
				throw new \Exception("This Auth does not use salting.", 1);				
			}

			// Apply the values to the record
			$this->setAttributes(array(
				$auth->saltField => $salt,
				$auth->passwordField => $password
			));

		}
649504
@Override
	public final Key keyFromPassword(char[] password) {
		try {
			SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
			int keyLength = Math.min(Cipher.getMaxAllowedKeyLength(algorithm), maximumKeyLength);
			KeySpec spec = new PBEKeySpec(password, salt, iterationCount, keyLength);
			SecretKey tmp = factory.generateSecret(spec);
			return new SecretKeySpec(tmp.getEncoded(), algorithm);
		} catch (NoSuchAlgorithmException e) {
			throw new RuntimeException(e);
		} catch (InvalidKeySpecException e) {
			throw new RuntimeException(e);
		}
	}
673237
function(password, salt) {
	var hash = npm_crypto.createHmac('sha512', salt); /** Hashing algorithm sha512 */
	hash.update(password);
	var value = hash.digest('hex');
	return {
		salt: salt,
		passwordHash: value
	};
}
1178421
public static function hash($password, $cost = null)
    {
        if ($cost === null) {
            $cost = self::DEFAULT_COST;
        }
        $prefix = sprintf('$%s$%02d$', self::PREFIX, $cost);
        $salt = self::createSalt();
        return crypt($password, $prefix.$salt);
    }
666540
public Proxy setSocksPassword(String password) {
    verifyProxyTypeCompatibility(ProxyType.MANUAL);
    this.proxyType = ProxyType.MANUAL;
    this.socksPassword = password;
    return this;
  }
587247
def hash_password(plaintextpw: str,
                  log_rounds: int = BCRYPT_DEFAULT_LOG_ROUNDS) -> str:
    
    salt = bcrypt.gensalt(log_rounds)  # optional parameter governs complexity
    hashedpw = bcrypt.hashpw(plaintextpw, salt)
    return hashedpw
871360
public static String computePasswordHash(final String password, final String salt) {
    return computePasswordHash(password, stringToSalt(salt));
  }
333412
public static String computePasswordHash(final String password, final byte[] salt) {
    if (StringMan.isEmpty(password))
      return (StringMan.encodeBytesToString(salt));
    final KeySpec spec = new PBEKeySpec(password.toCharArray(), salt, 2048, 160);
    SecretKeyFactory f;
    try {
      f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
      final byte[] hash = f.generateSecret(spec).getEncoded();
      return StringMan.encodeBytesToString(hash);
    } catch (final NoSuchAlgorithmException ex) {
      throw new RuntimeException("Missing encryption algorithm:", ex);
    } catch (final InvalidKeySpecException ex) {
      throw new RuntimeException("Key spec is incorrect.", ex);
    }
  }
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);
    }
  }