Click here to Skip to main content
15,889,838 members
Home / Discussions / C#
   

C#

 
GeneralRe: VB script to C# Pin
Alvaro Mendez3-Sep-03 6:29
Alvaro Mendez3-Sep-03 6:29 
GeneralRe: VB script to C# Pin
Majid Shahabfar3-Sep-03 19:03
Majid Shahabfar3-Sep-03 19:03 
GeneralRe: VB script to C# Pin
Corinna John4-Sep-03 2:00
Corinna John4-Sep-03 2:00 
GeneralRe: VB script to C# Pin
Majid Shahabfar6-Sep-03 3:42
Majid Shahabfar6-Sep-03 3:42 
GeneralRe: VB script to C# Pin
Richard Deeming5-Sep-03 8:05
mveRichard Deeming5-Sep-03 8:05 
GeneralRe: VB script to C# Pin
Majid Shahabfar6-Sep-03 3:43
Majid Shahabfar6-Sep-03 3:43 
GeneralRe: VB script to C# Pin
dog_spawn3-Sep-03 7:04
dog_spawn3-Sep-03 7:04 
QuestionRSA public key? Pin
ravingcoder3-Sep-03 4:05
ravingcoder3-Sep-03 4:05 
Hi, trying to encrypt something using RSAServiceProvide. I have two problems.

1. Bad data when decrypting.

(1) In prototype, RSA_Server instance in decrypting side and encrypting side is the same instance. Of course, this will change later.

RSAServiceProvider RSA_Server;

(2) On encrypting side:
RSA_Server = new RSACryptoServiceProvider();

encryptedbuffer = RSA_Server.Encrypt(
databuffer,
false);

NOTE: At first I was suspecting that databuffer is than 5 bytes. But I get same problem after I trimmed databuffer down to one bytes. Anyway, here's quote from MSDN:

"The length of the rgb parameter is greater than the maximum allowed length. If the fOAEP parameter is false and the encryption is performed on a computer with the high encryption pack installed, the maximum length of the rgb parameter is 16 bytes. If the high encryption pack is not installed, the maximum length of the rgb parameter is 5 bytes."

(3) On decrypting side:

plaintext = RSA_Server.Decrypt(encryptedbuffer, false);



2. How can I retrieve private key from RSAParameters instance? I need to "publish" my public key - not the entire RSAParameters. Here's code from MSDN:

//Good. PublicKey and "Exponent" are both byte array.
byte[] PublicKey = {214,46,220,83,160,73,40,39,201,155,19,202,3,11,191,178,56,
74,90,36,248,103,18,144,170,163,145,87,54,61,34,220,222,
207,137,149,173,14,92,120,206,222,158,28,40,24,30,16,175,
108,128,35,230,118,40,121,113,125,216,130,11,24,90,48,194,
240,105,44,76,34,57,249,228,125,80,38,9,136,29,117,207,139,
168,181,85,137,126,10,126,242,120,247,121,8,100,12,201,171,
38,226,193,180,190,117,177,87,143,242,213,11,44,180,113,93,
106,99,179,68,175,211,164,116,64,148,226,254,172,147};

byte[] Exponent = {1,0,1};


//Create a new instance of RSACryptoServiceProvider.
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();

//Create a new instance of RSAParameters.
RSAParameters RSAKeyInfo = new RSAParameters();

//Set RSAKeyInfo to the public key values.
RSAKeyInfo.Modulus = PublicKey; <--- OKAY, that's your public key.
RSAKeyInfo.Exponent = Exponent; <--- what da? Is this your private key?

//Import key parameters into RSA.
RSA.ImportParameters(RSAKeyInfo);

I need to pass encrypted data + RSA public key to decrypting side.

Thanks.
AnswerRe: RSA public key? Pin
ravingcoder3-Sep-03 17:12
ravingcoder3-Sep-03 17:12 
QuestionHow can we prevent a C++ Class from inheritance? Pin
sri sankaradoss3-Sep-03 1:59
sri sankaradoss3-Sep-03 1:59 
AnswerRe: How can we prevent a C++ Class from inheritance? Pin
Alvaro Mendez3-Sep-03 6:24
Alvaro Mendez3-Sep-03 6:24 
Generalruntime references Pin
wrzeszcz3-Sep-03 1:36
wrzeszcz3-Sep-03 1:36 
QuestionHow to pass an object to an exe Pin
Member 486393-Sep-03 1:08
Member 486393-Sep-03 1:08 
AnswerRe: How to pass an object to an exe Pin
dog_spawn3-Sep-03 1:34
dog_spawn3-Sep-03 1:34 
AnswerRe: How to pass an object to an exe Pin
Daniel Turini3-Sep-03 1:58
Daniel Turini3-Sep-03 1:58 
GeneralGetHashCode() Pin
deanoA3-Sep-03 0:18
deanoA3-Sep-03 0:18 
GeneralRe: GetHashCode() Pin
dog_spawn3-Sep-03 1:31
dog_spawn3-Sep-03 1:31 
GeneralRe: GetHashCode() Pin
freshthinking3-Sep-03 4:42
freshthinking3-Sep-03 4:42 
GeneralRe: GetHashCode() Pin
James T. Johnson3-Sep-03 6:54
James T. Johnson3-Sep-03 6:54 
GeneralRe: GetHashCode() Pin
dog_spawn3-Sep-03 7:06
dog_spawn3-Sep-03 7:06 
GeneralRe: GetHashCode() Pin
James T. Johnson3-Sep-03 7:09
James T. Johnson3-Sep-03 7:09 
GeneralRe: GetHashCode() Pin
--daljv--3-Sep-03 16:17
suss--daljv--3-Sep-03 16:17 
GeneralRe: GetHashCode() Pin
James T. Johnson3-Sep-03 7:07
James T. Johnson3-Sep-03 7:07 
GeneralRecordSelection in Crystal Reports Pin
Marix2-Sep-03 22:55
Marix2-Sep-03 22:55 
GeneralRe: RecordSelection in Crystal Reports Pin
Braulio Dez3-Sep-03 4:24
Braulio Dez3-Sep-03 4:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.