org.jasypt.salt
Class RandomSaltGenerator

Object
  extended by org.jasypt.salt.RandomSaltGenerator
All Implemented Interfaces:
SaltGenerator

public final 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.

This class is thread-safe.

Since:
1.2
Author:
Daniel Fernández Garrido

Constructor Summary
RandomSaltGenerator()
          Creates a new instance of RandomSaltGenerator
 
Method Summary
 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.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomSaltGenerator

public RandomSaltGenerator()
Creates a new instance of RandomSaltGenerator

Method Detail

generateSalt

public byte[] generateSalt(int lengthBytes)
Generate a random salt of the specified length in bytes.

Specified by:
generateSalt in interface SaltGenerator
Parameters:
lengthBytes - length in bytes.
Returns:
the generated salt.

includePlainSaltInEncryptionResults

public boolean includePlainSaltInEncryptionResults()
This salt generator needs the salt to be included unencrypted in encryption results, because of its being random. This method will always return true.

Specified by:
includePlainSaltInEncryptionResults in interface SaltGenerator
Returns:
true


Copyright © 2008 The JASYPT team. All Rights Reserved.