@Test public void runTest() { try { assertEquals( "5a27c13513ac42482cce07a543293c56dbfe06deb56634c1f2c6bd1cdeaab1bd373e22861d1f6c6785a406f0d75a7f247f87666b02d08f142c9097e8d40e6f17", PBKDF2.createHash("test input", "testsalt", 2, 512)); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (InvalidKeySpecException e) { e.printStackTrace(); } }
public static String createHash(String password, String salt, int iterations, int dkLen) throws NoSuchAlgorithmException, InvalidKeySpecException { byte[] saltBytes = salt.getBytes(StandardCharsets.UTF_8); byte[] hash = pbkdf2(password.toCharArray(), saltBytes, iterations, dkLen); return toHex(hash); }
PBKDF2 { public static String createHash(String password, String salt, int iterations, int dkLen) throws NoSuchAlgorithmException, InvalidKeySpecException { byte[] saltBytes = salt.getBytes(StandardCharsets.UTF_8); byte[] hash = pbkdf2(password.toCharArray(), saltBytes, iterations, dkLen); return toHex(hash); } }
PBKDF2 { public static String createHash(String password, String salt, int iterations, int dkLen) throws NoSuchAlgorithmException, InvalidKeySpecException { byte[] saltBytes = salt.getBytes(StandardCharsets.UTF_8); byte[] hash = pbkdf2(password.toCharArray(), saltBytes, iterations, dkLen); return toHex(hash); }  }
PBKDF2 { public static String createHash(String password, String salt, int iterations, int dkLen) throws NoSuchAlgorithmException, InvalidKeySpecException { byte[] saltBytes = salt.getBytes(StandardCharsets.UTF_8); byte[] hash = pbkdf2(password.toCharArray(), saltBytes, iterations, dkLen); return toHex(hash); }  static void main(String[] args); static String createHash(String password, String salt, int iterations, int dkLen); }
PBKDF2 { public static String createHash(String password, String salt, int iterations, int dkLen) throws NoSuchAlgorithmException, InvalidKeySpecException { byte[] saltBytes = salt.getBytes(StandardCharsets.UTF_8); byte[] hash = pbkdf2(password.toCharArray(), saltBytes, iterations, dkLen); return toHex(hash); }  static void main(String[] args); static String createHash(String password, String salt, int iterations, int dkLen);  }