Skip to content

Instantly share code, notes, and snippets.

@volker48
Created June 1, 2012 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save volker48/2853610 to your computer and use it in GitHub Desktop.
Save volker48/2853610 to your computer and use it in GitHub Desktop.
PBKDF2 Java sample
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
KeySpec keyspec = new PBEKeySpec("password".toCharArray(), salt, 1000, 128);
Key key = factory.generateSecret(keyspec);
System.out.println(key.getClass().getName());
System.out.println(Arrays.toString(key.getEncoded()));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment