Class EncryptionAlgorithm


  • public class EncryptionAlgorithm
    extends Algorithm
    An algorithm for performing symmetric encryption.
    • Method Detail

      • getAlg

        public EncryptionAlgorithm.Alg getAlg()
        Returns:
        The base algorithm, without the parameters. For example, the base algorithm of "AES/CBC/NoPadding" is "AES".
      • getKeyStrength

        public int getKeyStrength()
        Returns:
        The key strength of this algorithm in bits. Algorithms that use continuously variable key sizes (such as RC4) will return 0 to indicate they can use any key size.
      • fromString

        @Deprecated
        public static EncryptionAlgorithm fromString​(java.lang.String name)
                                              throws java.security.NoSuchAlgorithmException
        Deprecated.
        This method is deprecated because algorithm strings don't contain key length, which is necessary to distinguish between AES algorithms.
        Parameters:
        name - Algorithm name.
        Returns:
        Encryption algorithm.
        Throws:
        java.security.NoSuchAlgorithmException - If the algorithm is not found.
      • lookup

        public static EncryptionAlgorithm lookup​(java.lang.String algName,
                                                 java.lang.String modeName,
                                                 java.lang.String paddingName,
                                                 int keyStrength)
                                          throws java.security.NoSuchAlgorithmException
        Throws:
        java.security.NoSuchAlgorithmException
      • getBlockSize

        public int getBlockSize()
        Returns:
        The blocksize of the algorithm in bytes. Stream algorithms (such as RC4) have a blocksize of 1.
      • isPadded

        public boolean isPadded()
        Returns:
        true if this algorithm performs padding.
      • getIVLength

        public int getIVLength()
        Returns the number of bytes that this algorithm expects in its initialization vector.
        Returns:
        The size in bytes of the IV for this algorithm. A size of 0 means this algorithm does not take an IV.