I am creating C# API to provide android and iOS mobile application with data, I need to receive and send the data to the mobile applications as encrypted
so I used asymmetric encryption algorithm [RSA], and I have one more question regarding this.
- What is the best way to create public and private key and how can I store them.
- Is it write to send the public key as a plain text and is there any way to send it as .pem file?
- what is the public and private key formats used between mobile application and .net API?
I used this method to create the public and private keys
public static Tuple<string, string> CreateKeyPair()
{
CspParameters cspParams = new CspParameters { ProviderType = 1 /* PROV_RSA_FULL */ };
RSACryptoServiceProvider rsaProvider = new RSACryptoServiceProvider(1024, cspParams);
string publicKey = Convert.ToBase64String(rsaProvider.ExportCspBlob(false));
string privateKey = Convert.ToBase64String(rsaProvider.ExportCspBlob(true));
return new Tuple<string, string>(privateKey, publicKey);
}
but this function returns Base64String keys and this is not readable in mobile applications.
Please Advice,