Interface SaltGenerator

All Known Subinterfaces:
FixedSaltGenerator
All Known Implementing Classes:
ByteArrayFixedSaltGenerator, FixedByteArraySaltGenerator, FixedStringSaltGenerator, RandomSaltGenerator, StringFixedSaltGenerator, ZeroSaltGenerator

public interface SaltGenerator

Common interface for all salt generators which can be applied in digest or encryption operations.

Every implementation of this interface must be thread-safe.

Since:
1.2
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    generateSalt(int lengthBytes)
    This method will be called for requesting the generation of a new salt of the specified length.
    boolean
    Determines if the digests and encrypted messages created with a specific salt generator will include (prepended) the unencrypted salt itself, so that it can be used for matching and decryption operations.
  • Method Details

    • generateSalt

      byte[] generateSalt(int lengthBytes)

      This method will be called for requesting the generation of a new salt of the specified length.

      Parameters:
      lengthBytes - the requested length for the salt.
      Returns:
      the generated salt.
    • includePlainSaltInEncryptionResults

      boolean includePlainSaltInEncryptionResults()

      Determines if the digests and encrypted messages created with a specific salt generator will include (prepended) the unencrypted salt itself, so that it can be used for matching and decryption operations.

      Generally, including the salt unencrypted in encryption results will be mandatory for randomly generated salts, or for those generated in a non-predictable manner. Otherwise, digest matching and decryption operations will always fail. For fixed salts, inclusion will be optional (and in fact undesirable if we want to hide the salt value).

      Returns:
      whether the plain (unencrypted) salt has to be included in encryption results or not.