stoneharry

Untitled

May 13th, 2011
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace TestLogin
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.         }
  18.  
  19.         private void exit_Click(object sender, EventArgs e)
  20.         {
  21.             Application.Exit();
  22.         }
  23.  
  24.         private void login_Click(object sender, EventArgs e)
  25.         {
  26.             // Variable declaration
  27.             string user = username.Text;
  28.             string pass = password.Text;
  29.             string epass = pass;
  30.             string SearchValue = "1000111001111011110011100100001000011000011000011";
  31.             //int x = 8;
  32.             list.Items.Clear();
  33.             // A is swopped with 0, b is swopped with 1 etc (binary). The arrays to compare.
  34.             String[] chars = new string[26] { "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" };
  35.             String[] nums = new string[26] { "0", "1", "10", "11", "100", "101", "111", "1000", "1001", "1011", "1111", "10000", "10001", "10011", "10111", "11111", "100000",
  36.                                             "100001", "100011", "100111", "101111", "111111", "1000000", "1000001", "1000011", "1000111" };
  37.             // While we have not proccessed all the letters
  38.             for (int i = 0; i < 26; i++)
  39.             {
  40.                 // Debug
  41.                 list.Items.Add("i = " + i + ";  chars = " + chars[i] + ";   nums = " + nums[i] + ";");
  42.                 // Important part
  43.                 epass = epass.Replace(chars[i], nums[i]);
  44.                 // Debug
  45.                 list.Items.Add(epass);
  46.                 // Were not mean enough to implement this
  47.                 /*if (epass.Length >= x)
  48.                 {
  49.                     epass = epass.Insert(x, " ");
  50.                     x = x * 2;
  51.                 }*/
  52.             }
  53.             // If it's what were looking for but not the literal
  54.             if (user.Equals("admin") && epass.Equals(SearchValue) && !pass.Equals(SearchValue))
  55.             {
  56.                 success.Text = "Correct login.";
  57.                 login.Enabled = false;
  58.                 username.Enabled = false;
  59.                 password.Enabled = false;
  60.                 list.Items.Clear();
  61.                 list.Items.Add("You win! The password was: stoneharry");
  62.                 passcode.Text = "Pass Code: stoneharry";
  63.             }
  64.             else
  65.             {
  66.                 success.Text = "Incorrect details.";
  67.             }
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment