Ejemplo n.º 1
0
        public static int RunAndReturnExitCode(KeyOptions opts)
        {
            if (Directory.Exists(opts.KeyDir) == false)
            {
                Directory.CreateDirectory(opts.KeyDir);
            }
            if (Directory.Exists(opts.PrivateKeyDir) == false)
            {
                Directory.CreateDirectory(opts.PrivateKeyDir);
            }

            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

            //File.WriteAllText(
            //    Path.Combine(opts.KeyDir, opts.Name + "-public.xml"),
            //    rsa.ToXmlString(false));
            //File.WriteAllText(
            //    Path.Combine(opts.KeyDir, opts.Name + "-private.xml"),
            //    rsa.ToXmlString(true));

            File.WriteAllText(
                Path.Combine(opts.KeyDir, opts.Name + ".xml"),
                rsa.ToXmlString(false));

            File.WriteAllText(
                Path.Combine(opts.PrivateKeyDir, opts.Name + ".xml"),
                rsa.ToXmlString(true));

            return(0);
        }
Ejemplo n.º 2
0
 public static int Main(string[] args)
 {
     return(Parser.Default.ParseArguments <KeyOptions, TokenOptions>(args).MapResult(
                (KeyOptions opts) => KeyOptions.RunAndReturnExitCode(opts),
                (TokenOptions opts) => TokenOptions.RunAndReturnExitCode(opts),
                errs => 1));
 }
Ejemplo n.º 3
0
        public static int RunAndReturnExitCode(KeyOptions opts)
        {
            if (Directory.Exists(opts.KeyDir) == false) Directory.CreateDirectory(opts.KeyDir);
            if (Directory.Exists(opts.PrivateKeyDir) == false) Directory.CreateDirectory(opts.PrivateKeyDir);

            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
            //File.WriteAllText(
            //    Path.Combine(opts.KeyDir, opts.Name + "-public.xml"),
            //    rsa.ToXmlString(false));
            //File.WriteAllText(
            //    Path.Combine(opts.KeyDir, opts.Name + "-private.xml"),
            //    rsa.ToXmlString(true));

            File.WriteAllText(
                Path.Combine(opts.KeyDir, opts.Name + ".xml"),
                rsa.ToXmlString(false));

            File.WriteAllText(
                Path.Combine(opts.PrivateKeyDir, opts.Name + ".xml"),
                rsa.ToXmlString(true));

            return 0;
        }