Package org.jasypt.salt
Class StringFixedSaltGenerator
- java.lang.Object
-
- org.jasypt.salt.StringFixedSaltGenerator
-
- All Implemented Interfaces:
FixedSaltGenerator,SaltGenerator
public class StringFixedSaltGenerator extends java.lang.Object implements FixedSaltGenerator
String based implementation of
FixedSaltGenerator, that will always return the same salt. This salt is returned as bytes using the specified charset for conversion (UTF-8 by default).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 Modifier and Type Field Description private java.lang.Stringcharsetprivate static java.lang.StringDEFAULT_CHARSETprivate java.lang.Stringsaltprivate byte[]saltBytes
-
Constructor Summary
Constructors Constructor Description StringFixedSaltGenerator(java.lang.String salt)Creates a new instance of FixedStringSaltGenerator using the default charset.StringFixedSaltGenerator(java.lang.String salt, java.lang.String charset)Creates a new instance of FixedStringSaltGenerator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]generateSalt(int lengthBytes)Return salt with the specified byte length.booleanincludePlainSaltInEncryptionResults()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 Detail
-
DEFAULT_CHARSET
private static final java.lang.String DEFAULT_CHARSET
- See Also:
- Constant Field Values
-
salt
private final java.lang.String salt
-
charset
private final java.lang.String charset
-
saltBytes
private final byte[] saltBytes
-
-
Constructor Detail
-
StringFixedSaltGenerator
public StringFixedSaltGenerator(java.lang.String salt)
Creates a new instance of FixedStringSaltGenerator using the default charset.- Parameters:
salt- the specified salt.
-
StringFixedSaltGenerator
public StringFixedSaltGenerator(java.lang.String salt, java.lang.String charset)Creates a new instance of FixedStringSaltGenerator- Parameters:
salt- the specified salt.charset- the specified charset
-
-
Method Detail
-
generateSalt
public byte[] generateSalt(int lengthBytes)
Return salt with the specified byte length.- Specified by:
generateSaltin 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:
includePlainSaltInEncryptionResultsin interfaceSaltGenerator- Returns:
- false
-
-