コード例 #1
0
ファイル: Program.cs プロジェクト: laggage/RSAPractice
 void DisplayRSAKeyInXml(RSASecretKey key, bool showPublicKey = true, bool showPrivateKey = true)
 {
     if (showPrivateKey)
     {
         Write(ConsoleColor.Green, "PrivateKey:");
         Console.WriteLine(FormatXml(RSAKeyConverter.ToXmlPrivateKey(key.PrivateKey)));
     }
     if (showPublicKey)
     {
         Write(ConsoleColor.Green, "PublicKey:");
         Console.WriteLine(FormatXml(RSAKeyConverter.ToXmlPublicKey(key.PublicKey)));
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: laggage/RSAPractice
        void ShowDecryptPage()
        {
            Console.Clear();
            Console.WriteLine("----- C# RSA 操作示例 -----");
            int i = 0;

            foreach (RSASecretKey key in _generatedRSAKey)
            {
                Console.WriteLine("{0}:{1}", ++i, key.PrivateKey);
            }
            Console.Write("选择密钥:");
            int ch = int.Parse(Console.ReadLine());

            Console.Write("\r\n要解密的内容:");
            string content          = Console.ReadLine();
            string decryptedContent = RSADecrypt(/*_generatedRSAKey[ch - 1].PrivateKey*/ RSAKeyConverter.ToXmlPrivateKey(_generatedRSAKey[ch - 1].PrivateKey), content);

            Console.WriteLine("Result: {0}", decryptedContent);
            Console.ReadKey();
        }