· 7 years ago · Mar 08, 2018, 07:30 AM
1public class Key {
2 protected SecretKey key;
3
4 public Key(String password, String salt) throws NoSuchAlgorithmException, InvalidKeySpecException {
5 PBEKeySpec ks = new PBEKeySpec(password.toCharArray(), salt.getBytes(), 1000);
6 SecretKeyFactory kf = SecretKeyFactory.getInstance("PBEWithSHA1AndDESede");
7 key = kf.generateSecret(ks);
8
9 }
10
11 public SecretKey getKey() {
12 return key;
13 }
14}