public static PublicKey Generate(KeyType KeyType, CryptoAlgorithmID CryptoAlgorithmID) {
var CryptoProvider = CryptoCatalog.Default.GetAsymmetric(CryptoAlgorithmID);
CryptoProvider.Generate(GetKeySecurity(KeyType));
var KeyPair = CryptoProvider.KeyPair;
var PublicKey = new PublicKey();
PublicKey.KeyPair = KeyPair;
if (KeyPair.GetType() == typeof(RSAKeyPair)) {
PublicKey.PublicParameters = new PublicKeyRSA(KeyPair as RSAKeyPair);
return PublicKey;
}
throw new Exception("Not found");
}