svetlozar_kirkov

Encrypt XOR cipher (Exercise)

Oct 10th, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.Text.RegularExpressions;
  4.  
  5. namespace ConsoleTests
  6. {
  7.     class ConsoleTests
  8.     {
  9.         static void Main()
  10.         {
  11.             string input = Console.ReadLine();
  12.             string cipher = Console.ReadLine();
  13.             StringBuilder result = new StringBuilder();
  14.             for (int i = 0,j=0; i < input.Length; i++,j++)
  15.             {
  16.                 if (j>=cipher.Length)
  17.                 {
  18.                     j = 0;
  19.                 }
  20.                 int temp = (int)input[i] ^ (int)cipher[j];
  21.                 result.Append(String.Format("\\u{0:x4} ", temp).Trim());
  22.            
  23.             }
  24.             Console.WriteLine(result);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment