Brunet.Security.Utils.RSAPrivateKeyToDER.Main C# (CSharp) Method

Main() public static method

public static Main ( string args ) : void
args string
return void
  public static void Main(string[] args) {
    string path = args[0];
    byte[] blob = null;
    using(FileStream fs = File.Open(path, FileMode.Open)) {
      blob = new byte[fs.Length];
      fs.Read(blob, 0, blob.Length);
    }

    RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
    rsa.ImportCspBlob(blob);
    RSAParameters PrivateKey = rsa.ExportParameters(true);
    byte[] key = RSAKeyToASN1(PrivateKey);

    using(FileStream fs = File.Open(path + ".out", FileMode.Create)) {
      fs.Write(key, 0, key.Length);
    }

    Console.WriteLine("Your file is ready for you at " + path + ".out.");
  }
}