Generate an RSA public/private key pair.
public static int MakeKeys( string publicKeyFile, string privateKeyFile, string password, int bits, Rsa.PublicExponent exponent = Rsa.PublicExponent.Exp_EQ_65537, Rsa.PbeOptions pbes = Rsa.PbeOptions.Default, string paramString = "", Rsa.Format fileFormat = Rsa.Format.Default, bool showProgress = false )
Public Shared Function MakeKeys ( publicKeyFile As String, privateKeyFile As String, password As String, bits As Integer, Optional exponent As Rsa.PublicExponent = Rsa.PublicExponent.Exp_EQ_65537, Optional pbes As Rsa.PbeOptions = Rsa.PbeOptions.Default, Optional paramString As String = "", Optional fileFormat As Rsa.Format = Rsa.Format.Default, Optional showProgress As Boolean = false ) As Integer
Valid name-value pairs for paramString are:
| Parameter | Description |
|---|---|
| count=integer | To set the iteration count used in the PBKDF2 method, e.g. "count=5000;" [default=2048]. |
| prf=hmac-name | To change the HMAC algorithm used in the PBKDF2 method, e.g. "prf=hmacwithSHA256;" [default=hmacwithSHA1]. |
Valid values for hmac-name are one of {hmacWithSHA1, hmacWithSHA224, hmacWithSHA256, hmacWithSHA384, hmacWithSHA512}.
string pubkeyFile = "carol_pub.pem.txt"; string prikeyFile = "carol_epk.pem.txt"; int n = Rsa.MakeKeys(pubkeyFile, prikeyFile, "strong-password!", 2048, Rsa.PublicExponent.Exp_EQ_65537, Rsa.PbeOptions.Pbe_Pbkdf2_aes128_CBC, "count=3000;prf=hmacWithSHA256", Rsa.Format.PEM, true); Console.WriteLine("Rsa.MakeKeys returned {0}", n); Debug.Assert(n == 0, "Failed to create RSA key pair"); Console.WriteLine("Created public/private key pair OK");
VB6/C equivalent: RSA_MakeKeysXtd