Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- using System;
- using System.Linq;
- using System.Security.Cryptography;
- using System.Text;
- public class Program
- {
- static void Main()
- {
- Console.WriteLine("Select action:");
- Console.WriteLine("For encrypt text select - 1");
- Console.WriteLine("For decrypt text select - 2");
- int token = int.Parse(Console.ReadLine());
- var password = String.Empty;
- var textToEncrypt = String.Empty;
- var textToDecrypt = String.Empty;
- //var encryptedData = String.Empty;
- var encryptedData = SymmetricEncryptor.EncryptString(textToEncrypt, password);
- var decryptedText = SymmetricEncryptor.DecryptToString(encryptedData, password);
- switch (token)
- {
- //case encrypt
- case 1:
- Console.WriteLine("Insert phrase to encrypt text");
- password = Console.ReadLine();
- Console.WriteLine("Insert text to encrypt");
- textToEncrypt = Console.ReadLine();
- //Console.WriteLine("original text: {0}{1}{0}",
- // Environment.NewLine, textToEncrypt);
- //var encryptedData = SymmetricEncryptor.EncryptString(textToEncrypt, password);
- Console.WriteLine("encrypted data:{0}{1}{0}",
- Environment.NewLine, Convert.ToBase64String(encryptedData));
- break;
- //case decrypt
- case 2:
- Console.WriteLine("Insert phrase to decrypt text");
- password = Console.ReadLine();
- Console.WriteLine("Insert text to decrypt");
- //TODO: read from console strings and create encryptedData byte[] array
- textToDecrypt = Console.ReadLine();
- //byte[] bytes =
- //Console.WriteLine("original text: {0}{1}{0}",
- // Environment.NewLine, textToEncrypt);
- //var decryptedText = SymmetricEncryptor.DecryptToString(encryptedData, password);
- Console.WriteLine("decrypted text:{0}{1}{0}",
- Environment.NewLine, decryptedText);
- break;
- default:
- Console.WriteLine("error");
- break;
- }
- }
- }
Add Comment
Please, Sign In to add comment