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 BytesKeyGeneratorCreate 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 Details
-
secureRandom
Create aBytesKeyGeneratorthat uses aSecureRandomto generate keys of 8 bytes in length. -
secureRandom
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.
-
string
Creates aStringKeyGeneratorthat hex-encodesSecureRandomkeys of 8 bytes in length. The hex-encoded string is keyLength * 2 characters in length.
-