zoukankan      html  css  js  c++  java
  • KeyXMLStrings.cs

    using System;
    using System.IO;
    using System.Security.Cryptography;
    using System.Text;

    namespace APress.DotNetSecurity.Chapter2.KeyXMLStrings
    {
        class KeyXMLStringsTester
        {
            static void Main(string[] args)
            {
                try
                {
                    RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)RSA.Create();
                    Console.WriteLine("RSA public/private key info in XML is:");
                    Console.WriteLine(rsa.ToXmlString(true));
                    Console.WriteLine();
                    Console.WriteLine("RSA public key info in XML is:");
                    Console.WriteLine(rsa.ToXmlString(false));
                }
                catch(CryptographicUnexpectedOperationException cuoe)
                {
                    Console.WriteLine("CryptographicUnexpectedOperationException:  "
                        + cuoe.Message);
                    Console.WriteLine(cuoe.StackTrace);
                }
                catch(CryptographicException ce)
                {
                    Console.WriteLine("CryptographicException:  " + ce.Message);
                    Console.WriteLine(ce.StackTrace);
                }
                catch(Exception ge)
                {
                    Console.WriteLine("Exception:  " + ge.GetType().Name + " " + ge.Message);
                    Console.WriteLine(ge.StackTrace);
                }
                finally
                {
                    Console.WriteLine("Press the return key to continue...");
                    Console.Read();
                }
            }
            private static String ArrayToHexString(byte[] ByteData)
            {
                StringBuilder retVal = new StringBuilder();
                
                foreach(byte b in ByteData)
                {
                    retVal.Append(b.ToString("X2"));
                    retVal.Append(" ");
                }
                retVal.Remove(retVal.Length - 1, 1);

                return retVal.ToString();
            }    
        }
    }
  • 相关阅读:
    KNN算法
    mysql必须知道的
    励志的演讲
    30条程序员名言警句
    别人的文章:为什么软件开发,人多,事少,还会工作量大?
    分享一个比较受启发的文章“学历代表过去,能力代表现在,学习力代表未来”
    mvc 学前必知
    启动docker容器 防火墙问题报错 ! -i docker0' failed: iptables: No chain/target/match by that name.
    git指令详解总结
    git reset 版本回退的三种用法总结
  • 原文地址:https://www.cnblogs.com/shihao/p/2511225.html
Copyright © 2011-2022 走看看