Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Testing
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Encrypting
- string inputCode = Console.ReadLine();
- string encryptedText = string.Empty;
- for(int i = 0; i < inputCode.Length; i++)
- {
- encryptedText += (int)inputCode[i];
- }
- Console.WriteLine(encryptedText);
- //Decrypting
- string decryptedText = string.Empty;
- for (int i = 0; i < encryptedText.Length;)
- {
- int character = int.Parse(encryptedText.Substring(i, 2));
- char symbol = Convert.ToChar(character);
- if (char.IsLetterOrDigit(symbol) || (character >=32 && character<=47))
- {
- decryptedText += symbol;
- i += 2;
- continue;
- }
- else
- {
- int curentChar = int.Parse(encryptedText.Substring(i, 3));
- char currentSymbol = Convert.ToChar(curentChar);
- decryptedText += currentSymbol;
- i += 3;
- }
- }
- Console.WriteLine(decryptedText);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement