Package org.jasypt.iv

Class ByteArrayFixedIvGenerator

java.lang.Object
org.jasypt.iv.ByteArrayFixedIvGenerator
All Implemented Interfaces:
FixedIvGenerator, IvGenerator

public class ByteArrayFixedIvGenerator extends 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 final byte[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of FixedByteArrayIvGenerator
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    generateIv(int lengthBytes)
    Return iv with the specified byte length.
    boolean
    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 Details

    • iv

      private final byte[] iv
  • Constructor Details

    • ByteArrayFixedIvGenerator

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

    • 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