Here you can find the source of generateKey(char[] passphraseOrPin, byte[] salt)
public static SecretKey generateKey(char[] passphraseOrPin, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException
//package com.java2s; import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; import java.security.spec.KeySpec; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; public class Main { public static SecretKey generateKey(char[] passphraseOrPin, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException { final int iterations = 1000; final int outputKeyLength = 128; SecretKeyFactory secretKeyFactory = SecretKeyFactory .getInstance("PBKDF2WithHmacSHA1"); KeySpec keySpec = new PBEKeySpec(passphraseOrPin, salt, iterations, outputKeyLength);//w w w . j a v a 2s . c om SecretKey secretKey = secretKeyFactory.generateSecret(keySpec); return secretKey; } }