Class KeyGenerators
- java.lang.Object
-
- org.springframework.security.crypto.keygen.KeyGenerators
-
public class KeyGenerators extends java.lang.Object
Factory for commonly used key generators. Public API for constructing aBytesKeyGenerator
orStringKeyGenerator
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BytesKeyGenerator
secureRandom()
Create aBytesKeyGenerator
that uses aSecureRandom
to generate keys of 8 bytes in length.static BytesKeyGenerator
secureRandom(int keyLength)
Create aBytesKeyGenerator
that uses aSecureRandom
to generate keys of a custom length.static BytesKeyGenerator
shared(int keyLength)
Create aBytesKeyGenerator
that returns a single, sharedSecureRandom
key of a custom length.static StringKeyGenerator
string()
Creates aStringKeyGenerator
that hex-encodesSecureRandom
keys of 8 bytes in length.
-
-
-
Method Detail
-
secureRandom
public static BytesKeyGenerator secureRandom()
Create aBytesKeyGenerator
that uses aSecureRandom
to generate keys of 8 bytes in length.
-
secureRandom
public static BytesKeyGenerator secureRandom(int keyLength)
Create aBytesKeyGenerator
that uses aSecureRandom
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 aBytesKeyGenerator
that returns a single, sharedSecureRandom
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 aStringKeyGenerator
that hex-encodesSecureRandom
keys of 8 bytes in length. The hex-encoded string is keyLength * 2 characters in length.
-
-