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;
- using System.IO;
- using System.Drawing;
- using System.Drawing.Imaging;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- namespace WorldsWorstrotCpherOhandbtw2pacIsalive
- {
- class Program
- {
- [DllImport("User32", CharSet = CharSet.Auto)] // <--- needed for the wallpaper changing
- public static extern int SystemParametersInfo(int uiAction, int uiParam,
- string pvParam, uint fWinIni);
- static Random rnd = new Random();
- //static string[] alphabet = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
- static int movement = 0;
- static string word = "";
- static string[] newalpha = new string[alphabetget().Length];
- static int[] arr = Enumerable.Range(0, alphabetget().Length).OrderBy(c => rnd.Next()).ToArray();
- static int count = 0;
- static void Main(string[] args)
- {
- create_alphabet_file();
- take_inputs();
- create_shift_alphabet();
- justEndMeAlready();
- Console.ReadLine();
- }
- static void create_alphabet_file()
- {
- File.WriteAllText("alphabet.txt","a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z");
- }
- static string[] alphabetget()
- {
- return File.ReadAllText("alphabet.txt").Split(',');
- }
- //inputs
- static void take_inputs()
- {
- Console.WriteLine("Ceaser cypher program");
- Console.Write("Enter Text : ");
- word = Console.ReadLine();
- Console.Write("Enter shift : ");
- movement = Convert.ToInt16(Console.ReadLine());
- Console.WriteLine("Sit back and relax...");
- Console.WriteLine("This may take a while");
- }
- // outputs
- static void justEndMeAlready()
- {
- File.WriteAllText("output.txt", Cypher());
- System.Diagnostics.Process.Start("GUIinVisUalBasIc.exe"); //dont forget to put the compiled vb in the same folder as the exicuteing code here
- string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/victory.jpg";
- System.Threading.Thread.Sleep(4000);
- Screenshot();
- SystemParametersInfo(0x0014, 0, path, 0x0001);
- }
- // the big shuffle
- static void shuffle()
- {
- arr = Enumerable.Range(0, alphabetget().Length).OrderBy(c => rnd.Next()).ToArray();
- for(int i = 0; i < alphabetget().Length; i ++)
- {
- newalpha[i] = alphabetget()[arr[i]];
- count += 1;
- }
- }
- static void create_shift_alphabet()
- {
- bool done = false;
- int count = 0;
- while (done == false)
- {
- count += 1;
- shuffle();
- done = Check_array_shift();
- }
- Console.WriteLine(count.ToString()+ " " + showarrr());
- }
- // display arr for testing
- static string showarrr() // <----- Nnot needed for program exicution (left in the code anyway)
- {
- string output = "";
- for (int i = 0; i < alphabetget().Length; i++)
- {
- output += newalpha[i];
- }
- return output;
- }
- // forget about this for now
- static int Loop_Movement(int i) // helps the shift not fuck up when it gets to the end of an array
- {
- if ((movement + i) >= alphabetget().Length)
- {
- return (movement + i) - alphabetget().Length;
- }
- else return movement + i;
- }
- static bool Check_array_shift()// final utility check keeps some arbitery buffers updateing
- {
- bool check = true;
- for (int i = 0; i < alphabetget().Length; i++)
- {
- if (alphabetget()[Loop_Movement(i)] != newalpha[i])
- {
- check = false;
- }
- }
- return check;
- }
- // actual cyphering
- static string Cypher()
- {
- string output = "";
- for (int i = 0; i < word.Length; i++)
- {
- if (word[i].ToString() != " ")
- {
- for (int e = 0; e < alphabetget().Length; e++)
- {
- if (word[i].ToString() == alphabetget()[e]) output += newalpha[e];
- }
- }
- else
- {
- output += " ";
- }
- }
- return output;
- }
- // screenshotting utilitys
- static void Screenshot()
- {
- Rectangle bounds = Screen.GetBounds(Point.Empty);
- using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
- {
- using (Graphics g = Graphics.FromImage(bitmap))
- {
- g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
- }
- bitmap.Save(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/victory.jpg", ImageFormat.Jpeg);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement