/** * Crypts the given byte array * * @param input * byte array to be crypted * @param mode * crypt mode * @return the input crypted. Null in case of an error * @throws GeneralSecurityException */ protected final byte[] crypt(final byte[] input, final int mode) throws GeneralSecurityException { SecretKey key = generateSecretKey(); PBEParameterSpec spec = new PBEParameterSpec(salt, COUNT); Cipher ciph = Cipher.getInstance(CRYPT_METHOD); ciph.init(mode, key, spec); return ciph.doFinal(input); }
/** * Crypts the given byte array * * @param input * byte array to be crypted * @param mode * crypt mode * @return the input crypted. Null in case of an error * @throws GeneralSecurityException */ @Override protected final byte[] crypt(final byte[] input, final int mode) throws GeneralSecurityException { SecretKey key = generateSecretKey(); PBEParameterSpec spec = new PBEParameterSpec(salt, COUNT); Cipher ciph = Cipher.getInstance(CRYPT_METHOD); ciph.init(mode, key, spec); return ciph.doFinal(input); }
/** * Crypts the given byte array * * @param input * byte array to be encrypted * @param mode * crypt mode * @return the input crypted. Null in case of an error * @throws GeneralSecurityException */ @Override protected byte[] crypt(final byte[] input, final int mode) throws GeneralSecurityException { SecretKey key = generateSecretKey(); AlgorithmParameterSpec spec = createParameterSpec(); Cipher ciph = createCipher(key, spec, mode); return ciph.doFinal(input); }