Here you can find the source of generateHash(char[] password, byte[] salt)
public static byte[] generateHash(char[] password, byte[] salt)
//package com.java2s; //License from project: Open Source License import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; import java.util.Arrays; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; public class Main { public static final int KEY_LENGTH = 256; public static final int HASH_ITERATIONS = 1500; public static byte[] generateHash(char[] password, byte[] salt) { PBEKeySpec spec = new PBEKeySpec(password, salt, HASH_ITERATIONS, KEY_LENGTH); Arrays.fill(password, Character.MIN_VALUE); try {//from w w w. j a v a 2 s .c o m SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); return skf.generateSecret(spec).getEncoded(); } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { throw new AssertionError("Error while hashing a password: " + e.getMessage(), e); } finally { spec.clearPassword(); } } }