Package org.jasypt.salt
Class ByteArrayFixedSaltGenerator
java.lang.Object
org.jasypt.salt.ByteArrayFixedSaltGenerator
- All Implemented Interfaces:
FixedSaltGenerator
,SaltGenerator
Byte-array based implementation of FixedSaltGenerator
, that will
always return the same salt.
If the requested salt has a size in bytes smaller than the specified salt, the first n bytes are returned. If it is larger, an exception is thrown.
This class is thread-safe.
- Since:
- 1.9.2
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionByteArrayFixedSaltGenerator
(byte[] salt) Creates a new instance of FixedByteArraySaltGenerator -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
generateSalt
(int lengthBytes) Return salt with the specified byte length.boolean
As this salt generator provides a fixed salt, its inclusion unencrypted in encryption results is not necessary, and in fact not desirable (so that it remains hidden).
-
Field Details
-
salt
private final byte[] salt
-
-
Constructor Details
-
ByteArrayFixedSaltGenerator
public ByteArrayFixedSaltGenerator(byte[] salt) Creates a new instance of FixedByteArraySaltGenerator- Parameters:
salt
- the specified salt.
-
-
Method Details
-
generateSalt
public byte[] generateSalt(int lengthBytes) Return salt with the specified byte length.- Specified by:
generateSalt
in interfaceSaltGenerator
- Parameters:
lengthBytes
- length in bytes.- Returns:
- the generated salt.
-
includePlainSaltInEncryptionResults
public boolean includePlainSaltInEncryptionResults()As this salt generator provides a fixed salt, its inclusion unencrypted in encryption results is not necessary, and in fact not desirable (so that it remains hidden).- Specified by:
includePlainSaltInEncryptionResults
in interfaceSaltGenerator
- Returns:
- false
-