Montaque

Nothing is impossible for MS .NET

Get public key from certificate, and Convert the key to the RSAParameter

 byte[] pk = cer.GetPublicKey();
   byte[] m = new byte[pk.Length - 3];
   Buffer.BlockCopy(pk, 0, m, 0, m.Length);
   byte[] e = new byte[3];
   Buffer.BlockCopy(pk, m.Length, e, 0, 3);
   String key = "<RSAKeyValue><Modulus>" + Convert.ToBase64String(m)+"</Modulus><Exponent>"+Convert.ToBase64String(e)+"</Exponent></RSAKeyValue>";
   Console.WriteLine(key);
   RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
   rsa.FromXmlString(key);
   Console.WriteLine(rsa.ToXmlString(false));
Posted: Apr 08 2004, 12:28 PM by Montaque | with 6 comment(s)
Filed under:

Comments

Montaque said:

Here cer is a X509Certificate
# April 8, 2004 12:28 PM

Montaque said:

d
# September 28, 2004 3:01 PM

TrackBack said:

^_^,Pretty Good!
# April 12, 2005 11:12 PM

TrackBack said:

^_~
# April 16, 2005 2:37 AM

Montaque said:

excellent !! you fu'n rule, dude
contact me, please
nirvfan_mty (at) hot... blah blah blah

cheers
# August 4, 2005 2:06 PM

Get public key from certificate, and Convert the key to the RSAParameter said:

Pingback from  Get public key from certificate, and Convert the key to the RSAParameter

# December 5, 2007 4:34 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)