Pseudo-encryption

Posted by leemcd56 on March 18, 2012, 12:11 a.m.

I wrote a console-based pseudo-encryption program for shits and giggles using C# in MonoDevelop (I'm on a Mac, so cut me some slack).

using System;

namespace PseudoCrypt
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			//Force input string
			Start:
				Console.Write ("String to encrypt: ");
			
			//Check for input
			String strtoenc = Console.ReadLine ();
			
			//If it's blank, restart			
			if (strtoenc == "") goto Start;
			if (strtoenc.ToLower ().Trim () == "exit") goto Finish;
			
			//Retrieve a salt
			Salt:
				Console.Write ("Salt: ");
			
			//Check for input again
			String saltystr = Console.ReadLine ();
			
			if (saltystr == "") goto Salt;
			
			//Convert string from input to array[]
			char[] encstr = strtoenc.ToCharArray ();
			char[] salted  = saltystr.ToCharArray ();
			
			//String for cryption
			string crypt = "";
			int salt = 0;
			
			//Loop through each character of the salt
			for (int i = 0; i < salted.Length; i++) {
				salt += (int)salted[i];
			}
			
			if (salt == 0) goto Salt;
			
			//And loop through the string to crypt
			for (int j = 0; j < encstr.Length; j++) {
				int b = (int)encstr[j];				
				
				int c = ((b * 1024) / salt);
				
				crypt += (char)c;
			}
			
			//Make sure we can properly output
			if (crypt != "") {
				Console.WriteLine (crypt);
			} else {
				goto Start;
			}
			
			//Start all over again
			goto Start;
			
			Finish:
				Environment.Exit (0);
		}
	}
}

What do you think about it? What should I do to make it better? It's pseudo-encryption, so it's not really going to be used for anything but I could port it for C and make it official.

Comments

leemcd56 12 years, 9 months ago