Class KeyGenerators
- java.lang.Object
-
- org.springframework.security.crypto.keygen.KeyGenerators
-
public final class KeyGenerators extends java.lang.ObjectFactory for commonly used key generators. Public API for constructing aBytesKeyGeneratororStringKeyGenerator.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BytesKeyGeneratorsecureRandom()Create aBytesKeyGeneratorthat uses aSecureRandomto generate keys of 8 bytes in length.static BytesKeyGeneratorsecureRandom(int keyLength)Create aBytesKeyGeneratorthat uses aSecureRandomto generate keys of a custom length.static BytesKeyGeneratorshared(int keyLength)Create aBytesKeyGeneratorthat returns a single, sharedSecureRandomkey of a custom length.static StringKeyGeneratorstring()Creates aStringKeyGeneratorthat hex-encodesSecureRandomkeys of 8 bytes in length.
-
-
-
Method Detail
-
secureRandom
public static BytesKeyGenerator secureRandom()
Create aBytesKeyGeneratorthat uses aSecureRandomto generate keys of 8 bytes in length.
-
secureRandom
public static BytesKeyGenerator secureRandom(int keyLength)
Create aBytesKeyGeneratorthat uses aSecureRandomto 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 aBytesKeyGeneratorthat returns a single, sharedSecureRandomkey 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 aStringKeyGeneratorthat hex-encodesSecureRandomkeys of 8 bytes in length. The hex-encoded string is keyLength * 2 characters in length.
-
-