Interface AES


public interface AES
This interface provides methods for AES encryption and decryption.
  • Method Details

    • encrypt

      default byte[] encrypt(String str, String password)
      Encrypt string.
      Parameters:
      str - string
      password - password
      Returns:
      encrypted bytes
    • encrypt

      byte[] encrypt(byte[] src, String password)
      Encrypt byte array.
      Parameters:
      src - byte array
      password - password
      Returns:
      encrypted bytes
    • encrypt

      void encrypt(byte[] src, String password, OutputStream out) throws IOException
      Encrypt bytes and write the result into the stream.
      Parameters:
      src - bytes to encrypt
      password - password
      out - stream
      Throws:
      IOException - in case of error
    • encrypt

      default void encrypt(String str, String password, OutputStream out) throws IOException
      Encrypt string and write the result into the stream.
      Parameters:
      str - string to encrypt
      password - password
      out - stream
      Throws:
      IOException - in case of error
    • decrypt

      byte[] decrypt(byte[] bytes, String password)
      Decrypt byte array.
      Parameters:
      bytes - bytes to decrypt
      password - password to decrypt
      Returns:
      decrypted bytes
    • decryptString

      String decryptString(byte[] bytes, String password)
      Decrypt string
      Parameters:
      bytes - bytes to decrypt
      password - password to decrypt
      Returns:
      decrypted bytes
    • decrypt

      byte[] decrypt(InputStream in, String password) throws IOException
      Decrypt input stream. Stream must be obtained via getInputStream(InputStream, String).
      Parameters:
      in - stream to decrypt
      password - password to decrypt
      Returns:
      decrypted bytes
      Throws:
      IOException - in case of error
    • getInputStream

      InputStream getInputStream(InputStream in, String password) throws IOException
      Throws:
      IOException
    • getOutputStream

      OutputStream getOutputStream(OutputStream out, String password) throws IOException
      Throws:
      IOException
    • generate256key

      static byte[] generate256key(String password)
      Default 256-bit key generator. This implementation uses SHA-256 message digest algorithm.
      Parameters:
      password - password string
      Returns:
      key bytes
    • aes

      static AES aes(Function<String,byte[]> keyGen)
      Return AES instance with specified key generation function.
      Parameters:
      keyGen - key generation function
      Returns:
      in case of error
    • aes256

      static AES aes256()
      Return AES instance with default 256-bit key generation function. Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files for the appropriate JRE must be installed to use 256-bit keys.
      Returns:
      AES instance