Class CryptoCipher2

  • public class CryptoCipher2
    extends java.lang.Object
    This class provides encryption and decryption with AES/GCM/NoPadding. AES/GCM requires the key size shall be at least 128 bits (16 bytes). Currently, for string type key, we will convert it into 16 bytes data as the secret key. If you want to use more key size, you can directly provide the secrete key with byte array. But notices: AES only supports key sizes of 16, 24 or 32 bytes. For any invalid key size, exception will be thrown when calling CryptoCipher2. For encryption and decryption, we use plain text / cipher text and IV but not use Additional Authentication Data (AAD) as the input data. That is, we won't do any validating for the authentication tag. Currently createInputStream() functionality is not supported, may be fully implemented at later date.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description createInputStream​(com.microstrategy.utils.crypto.CryptoData stream, int mode)
      Not support creating input stream for now.
      com.microstrategy.utils.crypto.CryptoData decrypt​(com.microstrategy.utils.crypto.CryptoData iCiphertext)
      Decrypt the specified data.
      com.microstrategy.utils.crypto.CryptoData encrypt​(com.microstrategy.utils.crypto.CryptoData iPlainText)
      Encrypts the specified data.
      EnumCipher getEnumCipher()
      Get the encryption cipher.
      void setKey​(java.lang.String key)
      Set secret key with string for crypto cipher.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getEnumCipher

        public EnumCipher getEnumCipher()
        Get the encryption cipher.
        The encryption cipher.
      • decrypt

        public com.microstrategy.utils.crypto.CryptoData decrypt​(com.microstrategy.utils.crypto.CryptoData iCiphertext)
        Decrypt the specified data.
        iCiphertext - Data to be decrypted
        Decrypted data or null if the input data is not valid.
      • encrypt

        public com.microstrategy.utils.crypto.CryptoData encrypt​(com.microstrategy.utils.crypto.CryptoData iPlainText)
        Encrypts the specified data. Does not currently support adding additional authenticated data (AAD)
        iPlainText - Data to be encrypted
        Encrypted data.
      • createInputStream

        public createInputStream​(com.microstrategy.utils.crypto.CryptoData stream,
                                                     int mode)
        Not support creating input stream for now.
        stream -
        mode - Encrypt or decrypt mode
        Unsupported exception.
      • setKey

        public void setKey​(java.lang.String key)
        Set secret key with string for crypto cipher.
        key - Secret key