Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Sockets;
- using System.Numerics;
- using System.Text;
- class Program
- {
- public static string Decrypt(List<int> encrypted, string pass)
- {
- //assume pass.Length == 3
- int currentPos = 0;
- List<int> decrypted = new List<int>();
- foreach (int n in encrypted)
- {
- decrypted.Add(n ^ (int)pass[currentPos]);
- currentPos++;
- if (currentPos == 3)
- {
- currentPos = 2;
- }
- }
- string s = "";
- foreach (int n in decrypted)
- {
- s += (char)n;
- }
- return s;
- }
- [STAThread()]
- public static void Main(string[] args)
- {
- string path = @"C:\Users\owner\Documents\Quick Access\cipher1.txt";
- string data = "";
- using (StreamReader sr = new StreamReader(path))
- {
- data = sr.ReadToEnd();
- }
- List<int> encryptedNums = new List<int>();
- foreach (string s in data.Split(','))
- {
- encryptedNums.Add(Convert.ToInt32(s));
- }
- string encryptedString = "";
- //WTF????
- foreach (int n in encryptedNums)
- {
- try
- {
- encryptedString += (char)n;
- }
- catch (Exception)
- {
- Console.WriteLine(n);
- Console.ReadKey();
- }
- }
- string newPath = @"C:\Users\owner\Documents\Quick Access\cipher2.txt";
- for (char x = 'a'; x <= 'z'; x++)
- {
- for (char y = 'a'; y <= 'z'; y++)
- {
- for (char z = 'a'; z <= 'z'; z++)
- {
- string pass = x + "" + y + "" + z;
- string decrypted = Decrypt(encryptedNums, pass);
- Console.WriteLine("----PASS----");
- Console.WriteLine(pass);
- Console.WriteLine();
- Console.WriteLine();
- Console.WriteLine("-----DECRYPTED-----");
- Console.WriteLine(decrypted);
- Console.WriteLine();
- Console.WriteLine();
- Console.WriteLine("-----ENCRYPTED----");
- Console.WriteLine(encryptedString);
- Console.ReadKey();
- using (System.IO.StreamWriter file = new StreamWriter(newPath, true))
- {
- file.WriteLine("Decrypted with pass: " + pass + ":\n" + decrypted + "\n\n");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement