
com.github.ncredinburgh.tomcat.encryption.JCAKeyGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tomcat-external-propertysource Show documentation
Show all versions of tomcat-external-propertysource Show documentation
A Tomcat PropertySource class that reads provides property values from an external file.
package com.github.ncredinburgh.tomcat.encryption;
import java.security.GeneralSecurityException;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
public class JCAKeyGenerator {
private final String algorithmName;
public JCAKeyGenerator(String algorithmName) {
this.algorithmName = algorithmName;
}
public byte[] generateKey(int keySize) {
try {
KeyGenerator generator = KeyGenerator.getInstance(algorithmName);
generator.init(keySize);
SecretKey key = generator.generateKey();
byte[] keyBytes = key.getEncoded();
return keyBytes;
} catch (GeneralSecurityException e) {
throw new CipherException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy