Using Using Using Using Using Using Using Using Using Using Public Partial Class New New New New Double Int Int Int Char
Using Using Using Using Using Using Using Using Using Using Public Partial Class New New New New Double Int Int Int Char
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Cryptography;
using Microsoft.VisualBasic;
using System.Data.SqlClient;
using System.Data;
con.ConnectionString = "Data
Source=.\\SQLEXPRESS;AttachDbFilename=F:\\WebSite11\\App_Data\\Database.mdf;Integrated
Security=True;User Instance=True";
con.Open();
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
//Response.Redirect("WelcomePage.aspx");
//salting
ip = TextBox2.Text;
for (int i = 1; i <= 12; i++)
{
pos = objran.Next(1, charArr.Length);
if (strrandom.Contains(charArr.GetValue(pos).ToString()))
{
i--;
}
else
{
strrandom += charArr.GetValue(pos);
}
}
TextBox2.Text = ip + strrandom;
//encoding
ip = TextBox2.Text;
charArr = ip.ToCharArray();
for (int i = 0; i < ip.Length; i++)
{
asciivlue = (int)charArr[i];
x = (char)(asciivlue + 6);
encr += x;
}
TextBox2.Text = encr;
//rsa
TexttoEncrypt = encr;
encr = "";
TexttoEncrypt = TexttoEncrypt.Substring(0, TexttoEncrypt.Length - 12);
charArr = TexttoEncrypt.ToCharArray();
inx = 5; //objran.Next(0, 7);
//TextBox3.Text = TexttoEncrypt;
for (int i = 0; i < TexttoEncrypt.Length; i++)
{
asciivlue = getIntValue(charArr[i]);
// TextBox3.Text += asciivlue1;
//(Math.Pow(asciivlue, eKey(inx)) Mod (p * q)) Mod 26
v1 = pwr(asciivlue, eKey[inx]);
//v1 = Math.Floor(v1);
// TextBox3.Text += v1 + ",";
x = getChrValue((int)((pwr(asciivlue, eKey[inx]) % (p * q)) % 26));
encr += x;
}
// TextBox2.Text = encr;
// TextBox1.Text = encr;
// TextBox2.Text = "";
//database
cmd.CommandText = "Select * from Table1 where UID ='" + TextBox1.Text + "' and
Password ='" + encr + "'";
cmd.Connection = con;
sda.SelectCommand = cmd;
sda.Fill(ds, "Table1");
if (ds.Tables[0].Rows.Count > 0)
{
Label1.Text = "Login Successfull";
}
else
{
Label1.Text = "Login fail";
}
}
public double pwr(int no, int p)
{
double power = 1;
for (int i = 1; i <= p; i++)
{
power *= no;
}
return (power);
}
public int getIntValue(char ch)
{
switch (ch)
{
case 'a':
return (1);
case 'b':
return (2);
case 'c':
return (3);
case 'd':
return (4);
case 'e':
return (5);
case 'f':
return (6);
case 'g':
return (7);
case 'h':
return (8);
case 'i':
return (9);
case 'j':
return (10);
case 'k':
return (11);
case 'l':
return (12);
case 'm':
return (13);
case 'n':
return (14);
case 'o':
return (15);
case 'p':
return (16);
case 'q':
return (17);
case 'r':
return (18);
case 's':
return (19);
case 't':
return (20);
case 'u':
return (21);
case 'v':
return (22);
case 'w':
return (23);
case 'x':
return (24);
case 'y':
return (25);
case 'z':
return (26);
default:
return (0);
}
}
public char getChrValue(int ch)
{
// int ch1 = (int)ch;
switch (ch)
{
case 1:
return ('a');
case 2:
return ('b');
case 3:
return ('c');
case 4:
return ('d');
case 5:
return ('e');
case 6:
return ('f');
case 7:
return ('g');
case 8:
return ('h');
case 9:
return ('i');
case 10:
return ('j');
case 11:
return ('k');
case 12:
return ('l');
case 13:
return ('m');
case 14:
return ('n');
case 15:
return ('o');
case 16:
return ('p');
case 17:
return ('q');
case 18:
return ('r');
case 19:
return ('s');
case 20:
return ('t');
case 21:
return ('u');
case 22:
return ('v');
case 23:
return ('w');
case 24:
return ('x');
case 25:
return ('y');
case 26:
return ('z');
default:
return ('z');
}
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
}
}