@Test public void computeSha1() throws Exception { String P = "password"; byte[] S = "salt".getBytes(); int c = 1; int dkLen = 20; byte[] DK = Hex.decode("0c 60 c8 0f 96 1f 0e 71\n" + "f3 a9 b5 24 af 60 12 06\n" + "2f e0 37 a6"); final byte[] key = PBKDF2.derive(Sha1.class, P, S, c, dkLen); assertArrayEquals(DK, key); }
public static byte[] derive(Class<? extends Digest> hash, String password, byte[] salt, int c, int dkLen) { return new PBKDF2(hash, password, salt, c, dkLen).compute(); }
PBKDF2 { public static byte[] derive(Class<? extends Digest> hash, String password, byte[] salt, int c, int dkLen) { return new PBKDF2(hash, password, salt, c, dkLen).compute(); } }
PBKDF2 { public static byte[] derive(Class<? extends Digest> hash, String password, byte[] salt, int c, int dkLen) { return new PBKDF2(hash, password, salt, c, dkLen).compute(); } private  PBKDF2(Class<? extends Digest> hashClass,
                  String password,
                  byte[] salt,
                  int c,
                  int dkLen); }
PBKDF2 { public static byte[] derive(Class<? extends Digest> hash, String password, byte[] salt, int c, int dkLen) { return new PBKDF2(hash, password, salt, c, dkLen).compute(); } private  PBKDF2(Class<? extends Digest> hashClass,
                  String password,
                  byte[] salt,
                  int c,
                  int dkLen); static byte[] derive(Class<? extends Digest> hash, String password, byte[] salt, int c, int dkLen); }
PBKDF2 { public static byte[] derive(Class<? extends Digest> hash, String password, byte[] salt, int c, int dkLen) { return new PBKDF2(hash, password, salt, c, dkLen).compute(); } private  PBKDF2(Class<? extends Digest> hashClass,
                  String password,
                  byte[] salt,
                  int c,
                  int dkLen); static byte[] derive(Class<? extends Digest> hash, String password, byte[] salt, int c, int dkLen);  }