This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RsaToDerConverter | |
{ | |
public static String ExportPrivateKey(RSACryptoServiceProvider csp) | |
{ | |
TextWriter outputStream = new StringWriter(); | |
if (csp.PublicOnly) throw new ArgumentException("CSP does not contain a private key", "csp"); | |
var parameters = csp.ExportParameters(true); | |
using (var stream = new MemoryStream()) | |
{ | |
var writer = new BinaryWriter(stream); |