public class RandomSaltGenerator extends Object implements SaltGenerator
This implementation of SaltGenerator
holds a secure random
generator which can be used for generating random salts for encryption
or digesting.
The algorithm used for random number generation can be configured at instantiation time. If not, the default algorithm will be used.
This class is thread-safe.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_SECURE_RANDOM_ALGORITHM
The default algorithm to be used for secure random number
generation: set to SHA1PRNG.
|
Constructor and Description |
---|
RandomSaltGenerator()
Creates a new instance of RandomSaltGenerator using the
default secure random number generation algorithm.
|
RandomSaltGenerator(String secureRandomAlgorithm)
Creates a new instance of RandomSaltGenerator specifying a
secure random number generation algorithm.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
generateSalt(int lengthBytes)
Generate a random salt of the specified length in bytes.
|
boolean |
includePlainSaltInEncryptionResults()
This salt generator needs the salt to be included unencrypted in
encryption results, because of its being random.
|
public static final String DEFAULT_SECURE_RANDOM_ALGORITHM
public RandomSaltGenerator()
public RandomSaltGenerator(String secureRandomAlgorithm)
public byte[] generateSalt(int lengthBytes)
generateSalt
in interface SaltGenerator
lengthBytes
- length in bytes.public boolean includePlainSaltInEncryptionResults()
includePlainSaltInEncryptionResults
in interface SaltGenerator
Copyright © 2017 JBoss by Red Hat. All rights reserved.