|
-
Oct 21st, 2009, 05:54 AM
#1
Thread Starter
New Member
Problem with login system for my encrypter.
Im having a bit of trouble with getting my login system to cooperate with my encrypter/decrypter. When I test out my program, I find that my login system is not doing its job and even if I type my information wrong on the login, it will still encrypt/decrypt my text.(from form1) Here is my code. Hopefully someone can tell me what im missing.
vb.net Code:
Public Class Form1
Dim DES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
Dim Hash As New System.Security.Cryptography.MD5CryptoServiceProvider
Dim SecondForm As New LoginForm1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SecondForm.Show()
Try
DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox1.Text))
DES.Mode = Security.Cryptography.CipherMode.ECB
Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateEncryptor
Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox2.Text)
TextBox2.Text = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
Catch ex As Exception
MessageBox.Show("The following error(s) have occurred: " & ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SecondForm.Show()
Try
DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox1.Text))
DES.Mode = Security.Cryptography.CipherMode.ECB
Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateDecryptor
Dim Buffer As Byte() = Convert.FromBase64String(TextBox2.Text)
TextBox2.Text = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
Catch ex As Exception
MessageBox.Show("The following error(s) have occurred: " & ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class
Thanks In Advance.
-
Oct 21st, 2009, 05:57 AM
#2
Re: Problem with login system for my encrypter.
Where, in the code you posted, does it check for correct login information?
-
Oct 21st, 2009, 06:08 AM
#3
Thread Starter
New Member
Re: Problem with login system for my encrypter.
Sorry. I wasnt sure which part to post. but here is the other part.
vb.net Code:
Public Class LoginForm1
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
If UsernameTextBox.Text = "Jbknight3" And PasswordTextBox.Text = "Jbknight4" Then
MsgBox("Access Granted", MsgBoxStyle.Critical, "Granted")
Else
MsgBox("Wrong Username And/or Password!", MsgBoxStyle.Critical, "")
End If
If UsernameTextBox.Text = "" And PasswordTextBox.Text = "" Then
MsgBox("Type Something!", MsgBoxStyle.Critical, "")
End If
Me.Close()
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Me.Close()
End Sub
End Class
Last edited by Jbknight3; Oct 21st, 2009 at 06:18 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|