C# RSA and PHP
Arsium *****
331
Reputation points
Hello,
Currently, I'm trying to play with PHP SQL and C# but I got some problems with private and public keys + encryption and decryption. (I cannot write code in php here idk why : ''You don't have permission to access "http://learn.microsoft.com/answers/questions/ask.html" on this server.'') So I set a pastebin link with php code.
C# :
string key = ((string)json.rsaPublic).Replace("-----BEGIN PUBLIC KEY-----", "").Replace("-----END PUBLIC KEY-----", "");
byte[] toEncrypt = Encoding.UTF8.GetBytes(Utils.tempAESKey);
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
RSAParameters RSAKeyInfo = RSA.ExportParameters(false);
RSAKeyInfo.Modulus = Encoding.Default.GetBytes(key);//Public Key
RSA.ImportParameters(RSAKeyInfo);
string encryptedAESKey = Convert.ToBase64String(RSA.Encrypt(toEncrypt, false));
string sendAES = httpRequest.Post("requestWithencryptedAESKey").ToString();
MessageBox.Show(sendAES);//Empty