You could also use PemWriter to store them in PEM format: TextWriter textWriter = new StringWriter(); PemWriter pemWriter = new PemWriter(textWriter); pemWriter. WriteObject(keys. Private); pemWriter.Writer.Flush(); string privateKey = pemWriter.ToString().
Well, I don't know about the RSA-specific side, but once you've got an opaque binary string (i.e. It could contain any arbitrary data) the best bet for text conversion is Convert. ToBase64String(byte) which you can reverse with Convert.
FromBase64String(string). Do not use Encoding. GetString(byte) and Encoding.
GetBytes(string) for this - the binary data isn't text in a particular encoding, and shouldn't be treated as such. You're almost bound to lose data if you try this.
Thank you for your quick answer. I did as you said and as result I got this MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAJ7s/B4XNHmNa9LwZ91z... I think it should be a BigInteger no? Because in RSA we use numbers (p, q ...) – Skeenor Feb 23 at 12:41 The method name (GetDerEncoded) suggests that the returned data contains all RSA key parameters (p, q, ...) in DER encoded format.
– Christian Schwarz Feb 23 at 13:50 @Rami: Is your aim to get something you can "rehydrate" back to a PrivateKeyInfo? If so, you don't need to know the integers etc... you just want to make sure you can serialize to a byte array (and then to a string) and vice versa. – Jon Skeet Feb 23 at 13:57 @Christian thanks, so I have all the parameters back in one format.
Cool, but how can I divide it to get values of the (p, q...)? Any methods? Thanks again.
– Skeenor Feb 23 at 14:38 @Rami: Look at the rest of the Bouncy Castle API docs for a reverse operation to GetDerEncoded and ToAsn1Object. – Jon Skeet Feb 23 at 14:39.
If you convert the bouncycastle certificate to a . Net certificate. The function to do this is in the bouncycastle lib (i believe it's in a class called DotNetUtilities).
The RSACryptoServiceProvider has a function: ToXmlString(bool includePrivateKey). Which gives you an x representation of a certificate with if you want the private key containing all the components serialized to base64 seperately, exponent, modulus, and d (private exponent).
This might be what you are looking out for: rahulsingla.com/blog/2011/04/serializing....
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.