public class RandomIvGenerator extends Object implements IvGenerator
This implementation of IvGenerator
holds a secure random
generator which can be used for generating random initialization vectors (IV) for encryption.
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 |
---|
RandomIvGenerator()
Creates a new instance of RandomIvGenerator using the
default secure random number generation algorithm.
|
RandomIvGenerator(String secureRandomAlgorithm)
Creates a new instance of RandomIvGenerator specifying a
secure random number generation algorithm.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
generateIv(int lengthBytes)
Generate a random IV of the specified length in bytes.
|
boolean |
includePlainIvInEncryptionResults()
This IV generator needs the IV to be included unencrypted in
encryption results, because of its being random.
|
public static final String DEFAULT_SECURE_RANDOM_ALGORITHM
public RandomIvGenerator()
public RandomIvGenerator(String secureRandomAlgorithm)
public byte[] generateIv(int lengthBytes)
generateIv
in interface IvGenerator
lengthBytes
- length in bytes.public boolean includePlainIvInEncryptionResults()
includePlainIvInEncryptionResults
in interface IvGenerator
Copyright © 2021 JBoss by Red Hat. All rights reserved.