radidim

mainAESProgramm_01

Nov 4th, 2021 (edited)
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.97 KB | None | 0 0
  1. //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
  2. using System;
  3. using System.Linq;
  4. using System.Security.Cryptography;
  5. using System.Text;
  6.  
  7. public class Program
  8. {
  9.     static void Main()
  10.     {
  11.         Console.WriteLine("Select action:");
  12.         Console.WriteLine("For encrypt text select - 1");
  13.         Console.WriteLine("For decrypt text select - 2");
  14.  
  15.         int token = int.Parse(Console.ReadLine());
  16.  
  17.         var password = String.Empty;
  18.         var textToEncrypt = String.Empty;
  19.         var textToDecrypt = String.Empty;
  20.         //var encryptedData = String.Empty;
  21.         var encryptedData = SymmetricEncryptor.EncryptString(textToEncrypt, password);
  22.         var decryptedText = SymmetricEncryptor.DecryptToString(encryptedData, password);
  23.  
  24.  
  25.         switch (token)
  26.         {
  27.             //case encrypt
  28.             case 1:
  29.                 Console.WriteLine("Insert phrase to encrypt text");
  30.                 password = Console.ReadLine();
  31.                 Console.WriteLine("Insert text to encrypt");
  32.                 textToEncrypt = Console.ReadLine();
  33.  
  34.                 //Console.WriteLine("original text: {0}{1}{0}",
  35.                 //  Environment.NewLine, textToEncrypt);
  36.  
  37.                 //var encryptedData = SymmetricEncryptor.EncryptString(textToEncrypt, password);
  38.                 Console.WriteLine("encrypted data:{0}{1}{0}",
  39.                     Environment.NewLine, Convert.ToBase64String(encryptedData));
  40.                 break;
  41.  
  42.             //case decrypt
  43.             case 2:
  44.                 Console.WriteLine("Insert phrase to decrypt text");
  45.                 password = Console.ReadLine();
  46.                 Console.WriteLine("Insert text to decrypt");
  47.  
  48.                 //TODO: read from console strings and create encryptedData byte[] array
  49.  
  50.                 textToDecrypt = Console.ReadLine();
  51.                 //byte[] bytes =
  52.  
  53.                 //Console.WriteLine("original text: {0}{1}{0}",
  54.                 //  Environment.NewLine, textToEncrypt);
  55.  
  56.                 //var decryptedText = SymmetricEncryptor.DecryptToString(encryptedData, password);
  57.  
  58.                 Console.WriteLine("decrypted text:{0}{1}{0}",
  59.                     Environment.NewLine, decryptedText);
  60.                 break;
  61.             default:
  62.                 Console.WriteLine("error");
  63.                 break;
  64.         }
  65.     }
  66. }
Add Comment
Please, Sign In to add comment