SecureRandom random = new SecureRandom();
random.nextBytes(salt);
PBEKeySpec keyspec = new PBEKeySpec(password.toCharArray(), salt, 65536, 128);
- SecretKey key = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256").generateSecret(keyspec);
- key = new SecretKeySpec(key.getEncoded(), "AES");
+ SecretKey tmpkey = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256").generateSecret(keyspec);
+ this.key = new SecretKeySpec(tmpkey.getEncoded(), "AES");
} catch (Exception e) {
e.printStackTrace();
throw new Error("Failed generating key.");