/** * @return the key spec to be used for the configured crypt method */ protected KeySpec createKeySpec() { return new PBEKeySpec(getKey().toCharArray()); } }
/** * Generate the de-/encryption key. * <p> * Note: if you don't provide your own encryption key, the implementation will use a default. Be * aware that this is potential security risk. Thus make sure you always provide your own one. * * @return secretKey the security key generated * @throws NoSuchAlgorithmException * unable to find encryption algorithm specified * @throws InvalidKeySpecException * invalid encryption key */ private final SecretKey generateSecretKey() throws NoSuchAlgorithmException, InvalidKeySpecException { final PBEKeySpec spec = new PBEKeySpec(getKey().toCharArray()); return SecretKeyFactory.getInstance(CRYPT_METHOD).generateSecret(spec); } }
/** * Generate the de-/encryption key. * <p> * Note: if you don't provide your own encryption key, the implementation will use a default. Be * aware that this is potential security risk. Thus make sure you always provide your own one. * * @return secretKey the security key generated * @throws NoSuchAlgorithmException * unable to find encryption algorithm specified * @throws InvalidKeySpecException * invalid encryption key */ private final SecretKey generateSecretKey() throws NoSuchAlgorithmException, InvalidKeySpecException { final PBEKeySpec spec = new PBEKeySpec(getKey().toCharArray()); return SecretKeyFactory.getInstance(CRYPT_METHOD).generateSecret(spec); } }