I’m using C# to generate an RSA public/private key to encrypt user information. I need to make the public key and exponent available thought for other systems and languages. They will be signing the data and the C# web service will decrypt it and act upon it.
Right now, I have
RSA rsa = new RSACryptoServiceProvider(2048); // Generate a new 2048 bit RSA key
RSAParameters par = rsa.ExportParameters(false);
But the results for par.Exponent and par.Modulo are byte arrays. How can I convert the exponent to a string that can be parsed in another language. The samples in other languages I’ve seen seem to b
You could use a plain hex string or Base64 encoding – both are well-established methods of transporting binary data as a string:
(Note that if you’re not using .NET4 then you’ll need to pass an array to the
Concatmethod rather than anIEnumerable<T>. You can do this easily enough by bolting aToArraycall onto theSelect.)