Class AesCbcCryptoUtil


  • public class AesCbcCryptoUtil
    extends Object
    AES/CBC/PKCS5PADDING coding
    Since:
    2.5.0
    Author:
    imre.scheffer
    • Field Detail

      • DEFAULT_VECTOR

        public static final byte[] DEFAULT_VECTOR
        Default zero initial vector
      • CIPHER_TRANSFORMATION

        public static final String CIPHER_TRANSFORMATION
        Cipher transformation algotithm
        See Also:
        Constant Field Values
    • Method Detail

      • encrypt

        public static byte[] encrypt​(byte[] dataToEncrypt,
                                     char[] key)
                              throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Encrypt data with parameters, initial vector is default zero
        Parameters:
        dataToEncrypt - data to encrypt
        key - encrypting key
        Returns:
        encrypted data in byte[]
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - if any error
      • encrypt

        public static InputStream encrypt​(InputStream dataToEncrypt,
                                          char[] key)
                                   throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Encrypt data with parameters, initial vector is default zero
        Parameters:
        dataToEncrypt - data to encrypt
        key - encrypting key
        Returns:
        encrypted data in InputStream
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - if any error
      • encrypt

        public static byte[] encrypt​(byte[] dataToEncrypt,
                                     char[] key,
                                     String initVector)
                              throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Encrypt data with parameters
        Parameters:
        dataToEncrypt - data to encrypt
        key - encrypting key
        initVector - initial vector
        Returns:
        encrypted data in byte[]
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - if any error
      • encrypt

        public static InputStream encrypt​(InputStream dataToEncrypt,
                                          char[] key,
                                          String initVector)
                                   throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Encrypt data with parameters
        Parameters:
        dataToEncrypt - data to encrypt
        key - encrypting key
        initVector - initial vector
        Returns:
        encrypted data in InputStream
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - if any error
      • decrypt

        public static byte[] decrypt​(byte[] encryptedData,
                                     char[] key)
                              throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Decrypt data with parameters, initial vector is default zero
        Parameters:
        encryptedData - encrypted data
        key - decrypting key
        Returns:
        decrypted data in byte[]
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - if any error
      • decrypt

        public static InputStream decrypt​(InputStream encryptedData,
                                          char[] key)
                                   throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Decrypt data with parameters, initial vector is default zero
        Parameters:
        encryptedData - encrypted data
        key - decrypting key
        Returns:
        decrypted data in InputStream
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - if any error
      • decrypt

        public static byte[] decrypt​(byte[] encryptedData,
                                     char[] key,
                                     String initVector)
                              throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Decrypt data with parameters
        Parameters:
        encryptedData - encrypted data
        key - decrypting key
        initVector - initial vector
        Returns:
        decrypted data in byte[]
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - if any error
      • decrypt

        public static InputStream decrypt​(InputStream encryptedData,
                                          char[] key,
                                          String initVector)
                                   throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Decrypt data with parameters
        Parameters:
        encryptedData - encrypted data
        key - decrypting key
        initVector - initial vector
        Returns:
        decrypted data in InputStream
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - if any error
      • to16LengthInitVector

        public static String to16LengthInitVector​(String sourceString)
        Truncate/expand InitVector source string to 16-length string
        Parameters:
        sourceString - any string for InitVector
        Returns:
        16-length String