As seen in the previous section on encryption, Spring Security has a class, namely org.springframework.security.crypto.keygen.KeyGenerators, that has a number of factory methods that can used to construct a number of keys needed for your application.
The following are the two supported types of key generator:
- BytesKeyGenerator: The generator for generating unique byte array-based keys.
- StringKeyGenerator: The generator for unique string keys:
Figure 7: The BytesKeyGenerator and StringKeyGenerator factory methods