org.springframework.security.crypto.keygen
Class KeyGenerators

java.lang.Object
  extended by org.springframework.security.crypto.keygen.KeyGenerators

public class KeyGenerators
extends Object

Factory for commonly used key generators. Public API for constructing a BytesKeyGenerator or StringKeyGenerator.


Method Summary
static BytesKeyGenerator secureRandom()
          Create a BytesKeyGenerator that uses a SecureRandom to generate keys of 8 bytes in length.
static BytesKeyGenerator secureRandom(int keyLength)
          Create a BytesKeyGenerator that uses a SecureRandom to generate keys of a custom length.
static BytesKeyGenerator shared(int keyLength)
          Create a BytesKeyGenerator that returns a single, shared SecureRandom key of a custom length.
static StringKeyGenerator string()
          Creates a StringKeyGenerator that hex-encodes SecureRandom keys of 8 bytes in length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

secureRandom

public static BytesKeyGenerator secureRandom()
Create a BytesKeyGenerator that uses a SecureRandom to generate keys of 8 bytes in length.


secureRandom

public static BytesKeyGenerator secureRandom(int keyLength)
Create a BytesKeyGenerator that uses a SecureRandom to generate keys of a custom length.

Parameters:
keyLength - the key length in bytes, e.g. 16, for a 16 byte key.

shared

public static BytesKeyGenerator shared(int keyLength)
Create a BytesKeyGenerator that returns a single, shared SecureRandom key of a custom length.

Parameters:
keyLength - the key length in bytes, e.g. 16, for a 16 byte key.

string

public static StringKeyGenerator string()
Creates a StringKeyGenerator that hex-encodes SecureRandom keys of 8 bytes in length. The hex-encoded string is keyLength * 2 characters in length.