getRsaKeyPair function
AsymmetricKeyPair<PublicKey, PrivateKey>
getRsaKeyPair(
- SecureRandom secureRandom
Generate a PublicKey
and PrivateKey
pair
Returns a AsymmetricKeyPair
based on the RSAKeyGenerator
with custom parameters,
including a SecureRandom
Implementation
AsymmetricKeyPair<PublicKey, PrivateKey> getRsaKeyPair(
SecureRandom secureRandom) {
/// Set BitStrength to [1024, 2048 or 4096]
var rsapars = new RSAKeyGeneratorParameters(BigInt.from(65537), 2048, 5);
var params = new ParametersWithRandom(rsapars, secureRandom);
var keyGenerator = new RSAKeyGenerator();
keyGenerator.init(params);
return keyGenerator.generateKeyPair();
}