I have this Java code to create a public key based on base64 byte array in Java:
return KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(base64PublicKeyBytes));
That line is subsequently used to encrypt some data.
Assume that I have access to the base64 encoded public key string.
Would the equivalent C# code to generate the key be as simple as:
base64PublicKeyBytes = Convert.FromBase64String(base64PublicKey);
and this can then be used with RSACryptoServiceProvider as follows:
var rsa = new RSACryptoServiceProvider(2048);
var rsaKeyInfo = rsa.ExportParameters(false);
rsaKeyInfo.Modulus = base64PublicKeyBytes;