Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Collections.Generic;
- using System.Threading;
- class keyEncrypt
- {
- static void Main(string[] args)
- {
- string pass = "";
- if (args.Length == 1) {
- // argument is the password requesting encryption
- pass = args[0];
- } else {
- // ask for password for encryption
- Console.WriteLine("Password to encrypt:");
- pass = Console.ReadLine();
- }
- Console.WriteLine("Encrypting...");
- // encrypt all with simple K power encrypition
- string spass = "";
- foreach(char c in pass)
- spass += (c ^ 'K');
- // siphon string of numbers by sets of 2 into bytes
- double a = spass.Length/2.0;
- double len = Math.Ceiling(a);
- List<byte> npass = new List<byte>();
- for (int i = 0; i < len; i++)
- {
- try {
- npass.Add((byte)Convert.ToInt32(spass.Substring(i, 2)));
- } catch {
- // assume we bugged because we're asking for a length that cannot be used
- npass.Add((byte)Convert.ToInt32(spass.Substring(i, 1)));
- }
- }
- byte[] buf = npass
- .ToArray();
- // convert to string
- string newpass = System.Text.Encoding.UTF8.GetString(buf);
- // debug outputs
- Console.WriteLine("- Length of Password: "+pass.Length);
- Console.WriteLine("- Length of encryption: "+spass.Length);
- Console.WriteLine("- a: "+a+", len: "+len);
- Console.WriteLine("- Length of list: "+npass.Count);
- Console.WriteLine("- Length of array: "+buf.Length);
- Console.WriteLine("Password: '"+newpass+"'");
- Console.WriteLine("Goodbye! -Komak57");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment