rsa encrypt/decrypt
From: Taryon (taryon_at_terra.com.br)
Date: 09/11/03
- Next message: Keith Patrick: "Is it secure to not refuse permissions in a non-referenced assembly?"
- Previous message: bill: "security"
- Next in thread: Pieter Philippaerts: "Re: rsa encrypt/decrypt"
- Reply: Pieter Philippaerts: "Re: rsa encrypt/decrypt"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 11 Sep 2003 15:02:18 -0300
hi all!
i am using the rsa to encrypt one password on the server and decrypt it on
the client. The server code is:
ASCIIEncoding UEConv = new ASCIIEncoding();
fs = new FileStream("pb"+conta+".txt",FileMode.Open);
StreamReader sr = new StreamReader(fs);
String rsaPubKey = sr.ReadToEnd();
rsa.FromXmlString(rsaPubKey);
fs.Close();
byte[] plaintext = UEConv.GetBytes(keyinuse);
byte[] ciphertext = rsa.Encrypt(plaintext,false);
string chave=new String(UEConv.GetChars(ciphertext));
and in the client i have this:
ASCIIEncoding BC = new ASCIIEncoding();
byte[] ciphertext = BC.GetBytes(serverrespkey);
fs = new FileStream(privfile,FileMode.Open);
StreamReader sr1 = new StreamReader(fs);
String rsaPrivKey = sr1.ReadToEnd();
rsa.FromXmlString(rsaPrivKey);
fs.Close();
byte[] rgbPlainText = rsa.Decrypt(ciphertext,false);
string keyinuse=new String(BC.GetChars(rgbPlainText));
exactly in the decrypt line i got a BAD DATA. I look through the watch that
the result of the encryption is equal to the ciphertext in the decrypt.
any idea?
PS. the Client receive the serverrespkey through a socket connection and
this connection is working fine to no crypted texts.
- Next message: Keith Patrick: "Is it secure to not refuse permissions in a non-referenced assembly?"
- Previous message: bill: "security"
- Next in thread: Pieter Philippaerts: "Re: rsa encrypt/decrypt"
- Reply: Pieter Philippaerts: "Re: rsa encrypt/decrypt"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|