I am using RSA to encrypted text and then send the encryptedtext to server ,My problem is the server unable to decrypted text because the server can not read encryptedtext correct , my code in client is :
byte[] plaintext;
byte[] encryptedtext=new byte[128];
plaintext = ByteConverter.GetBytes("hello");
encryptedtext = Encryption(plaintext, RSAA.ExportParameters(false), false);
textBox10.Text = ByteConverter.GetString(encryptedtext);
byte[] bytesToSend = ASCIIEncoding.ASCII.GetBytes(textBox10.Text);
networkStream.Write(bytesToSend, 0, bytesToSend.Length);
my code in server :
byte[] buffer = new byte[handlerSocket.ReceiveBufferSize];
dataReceived = Encoding.ASCII.GetString(buffer, 0, buffer.Length);
byte[] encryptedtext=new byte[128] ;
encryptedtext = ByteConverter.GetBytes(dataReceived);
byte[] decryptedtex = Decryption(encryptedtext, RSA.ExportParameters(true), false);
if(decryptedtex!=null)
textBox4.Text = ByteConverter.GetString(decryptedtex);
output :
in client the encrypted text : 卅凉䂧즠淦燺◓㎜ზᄋ큺�㬧ᶥ숿둴ꖉ넵Տ懾쵌摘䙑원퀮歒�숈鬖姈㫑餓貜Dž手葏㻐㺿⣨ꇑ橿朁繱�䘧殍㲙㦱䟽躮Ồᒛ鈉嫡짟
but when the encrypted text recive to server is : ????????????????????????????????????????????????????????? and the server can not Decryption the text
so How I can solve this problem ?
What I have tried:
my code in my question can any body help ? thanks in advance