Class Encryption

java.lang.Object
utils.Encryption

public class Encryption extends Object
  • Constructor Details

  • Method Details

    • generateIV

      public byte[] generateIV()
      Generates a new IV based on the set size
      Returns:
      the new IV
    • encrypt

      public InputStream encrypt(InputStream inputStream) throws EncryptionException
      Encrypts the provided input stream and returns it
      Parameters:
      inputStream - The input stream to encrypt
      Returns:
      The encrypted input stream
      Throws:
      EncryptionException - if the encryption fails
    • decrypt

      public InputStream decrypt(InputStream inputStream) throws EncryptionException
      Decrypts a passed input stream and returns it. Note that this method will not produce any meaningful output if the IV used on decryption isd different from the one used on encryption
      Parameters:
      inputStream - The input stream to decrypt
      Returns:
      The decrypted input stream
      Throws:
      EncryptionException
    • encryptionCipher

      public Cipher encryptionCipher(byte[] IV) throws EncryptionException
      Generates an encryption cipher based on the passed IV
      Parameters:
      IV - The IV to use
      Returns:
      The encryption cipher
      Throws:
      EncryptionException - If the cipher generation fails
    • decryptionCipher

      public Cipher decryptionCipher(byte[] IV) throws EncryptionException
      Generates a decryption cipher
      Parameters:
      IV - The IV to use
      Returns:
      The generated cipher
      Throws:
      EncryptionException