Class KeyGenerators
java.lang.Object
org.springframework.security.crypto.keygen.KeyGenerators
Factory for commonly used key generators. Public API for constructing a
BytesKeyGenerator
or StringKeyGenerator
.-
Method Summary
Modifier and TypeMethodDescriptionstatic BytesKeyGenerator
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 Details
-
secureRandom
Create aBytesKeyGenerator
that uses aSecureRandom
to generate keys of 8 bytes in length. -
secureRandom
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.
-
string
Creates aStringKeyGenerator
that hex-encodesSecureRandom
keys of 8 bytes in length. The hex-encoded string is keyLength * 2 characters in length.
-