Package org.jasypt.iv

Class ByteArrayFixedIvGenerator

  • All Implemented Interfaces:
    FixedIvGenerator, IvGenerator

    public class ByteArrayFixedIvGenerator
    extends java.lang.Object
    implements FixedIvGenerator

    Byte-array based implementation of FixedIvGenerator, that will always return the same initialization vector (IV).

    If the requested IV has a size in bytes smaller than the specified IV, the first n bytes are returned. If it is larger, an exception is thrown.

    This class is thread-safe.

    Since:
    1.9.3
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private byte[] iv  
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteArrayFixedIvGenerator​(byte[] iv)
      Creates a new instance of FixedByteArrayIvGenerator
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] generateIv​(int lengthBytes)
      Return iv with the specified byte length.
      boolean includePlainIvInEncryptionResults()
      As this iv generator provides a fixed iv, its inclusion unencrypted in encryption results is not necessary, and in fact not desirable (so that it remains hidden).
      • Methods inherited from class java.lang.Object

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

      • iv

        private final byte[] iv
    • Constructor Detail

      • ByteArrayFixedIvGenerator

        public ByteArrayFixedIvGenerator​(byte[] iv)
        Creates a new instance of FixedByteArrayIvGenerator
        Parameters:
        iv - the specified iv.
    • Method Detail

      • generateIv

        public byte[] generateIv​(int lengthBytes)
        Return iv with the specified byte length.
        Specified by:
        generateIv in interface IvGenerator
        Parameters:
        lengthBytes - length in bytes.
        Returns:
        the generated iv.
      • includePlainIvInEncryptionResults

        public boolean includePlainIvInEncryptionResults()
        As this iv generator provides a fixed iv, its inclusion unencrypted in encryption results is not necessary, and in fact not desirable (so that it remains hidden).
        Specified by:
        includePlainIvInEncryptionResults in interface IvGenerator
        Returns:
        false