TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Stefan
NA
7
0
Beginner needs help with passwords
Jan 23 2009 8:45 PM
Can anyone show me how to encrypt and store a password in a database. I am currently storing them in clear text in a text file.
here's my code:
this is the form I use to ask for input:
private void button1_Click(object sender, EventArgs e)
{
string username = textBox1.Text;
string password = textBox2.Text;
using (StreamWriter wr = System.IO.File.AppendText("C:\\pass.txt"))
{
wr.WriteLine(username + "," + password);
}
this.Close();
}
this is the log in form:
private void button1_Click(object sender, EventArgs e)
{
using (StreamReader reader = new StreamReader("C:\\pass.txt"))
{
string[] allLines = File.ReadAllLines(@"C:\pass.txt");
string[] usernames = new string[allLines.Length];
string[] passwords = new string[allLines.Length];
for (int i = 0; i < allLines.Length; i++)
{
string[] lineSplit = allLines[i].Split(',');
usernames[i] = lineSplit[0];
passwords[i] = lineSplit[1];
}
string username = textBox1.Text;
string password = textBox2.Text;
for (int i = 0; i < usernames.Length; i++)
if (usernames[i] == username)
if (passwords[i] == password)
{
this.Hide();
Form3 frm = new Form3();
frm.Show();
return;
}
else
{
MessageBox.Show("Incorrect username/password.");
return;
}
MessageBox.Show("Incorrect username/password.");
}
}
Any help will be appreciated.
Reply
Answers (
1
)
Socket Data Rate
progess bar problem