• 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();
            }    
        }
    }
  • 相关阅读:
    使用JS实现网页动态换肤
    数据库更新Sql脚本总结
    Javascript无刷新获取当前时间
    ASP.NET将网页设为桌面图标实现
    解决在IE浏览器中resize事件执行多次
    linux编译安装gcc5.3.0
    JAVA抽象类和接口
    JAVA内部类
    推测竞赛中测试集的正负比例
    Codeforces Round #742 (Div. 2) 题解
  • 原文地址:https://www.cnblogs.com/shihao/p/2511225.html
Copyright © 2020-2023  润新知