Some James Bond Shit
Back from school holiday break and back with some more programming. I've been looking at how to encrypt data and strings in Visual Basic. some quick Google dearching brings up this Encrypting and Decrypting Strings Walkthrough on MSDN. Applying the code, I attempt to create a login interface that simply encrypts the users password with a built in key. I understand that the key should theoretically also be encrypted and not left as plain text in the program, but thats outside of the scope of this program at the moment.
I've currently run into repeated NullException errors and am having difficulty sotring the problem, though they seem to be caused by dynamic arrays. It also seems to be no assigning values to parts of arrays in the Global Variables Module. This code is in progress and poorly commented and unoptimised. It also doesn't work :P
Language: Visual Basic 2015
The task: Successfully create a securely encrypted login system.
Login Form
[Show][Hide]
Public Class Form1 ' FORM LOAD Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ' UI Setup boxUsername.DropDownStyle = 2 If usercount = 0 Then MsgBox("Welcome, Please Create A User Account.") Form2.ShowDialog() End If For loops = 0 To usercount boxUsername.Items.Add(username(loops)) Next End Sub ' LOG IN BUTTON Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click End Sub ' CREATE ACCOUNT BUTTON Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Form2.Show() End Sub End Class
Create Account Form
[Show][Hide]
Public Class Form2 Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click If txtPassword.Text = txtPasswordConfirm.Text Then username(usercount) = txtUsername.Text password(usercount) = txtPassword.Text usercount += 1 Else MsgBox("Passwords Do No Match, Please Try Again.") txtUsername.Text = "" : txtPassword.Text = "" : txtPasswordConfirm.Text = "" End If Dim exportfile As IO.StreamWriter exportfile = IO.File.AppendText("usersencrypted.txt") Dim wrapper As New Simple3Des(key) Dim cipherText(9999) As String Dim plaintext As String For loops = 0 To username.Length plaintext = password(loops) cipherText(loops) = wrapper.EncryptData(plaintext) exportfile.WriteLine(cipherText(loops)) loops += 1 Next MsgBox("User Acccount Created Successfully.") Form1.Show() End Sub Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub Private Sub txtUsername_TextChanged(sender As Object, e As EventArgs) Handles txtUsername.TextChanged End Sub End Class
Variable Module
[Show][Hide]
Module Module2 Public username(9999) As String Public password(9999) As String Public key As String = "temporarykey" Public usercount As Integer = 0 End Module
Done for today, I'm getting an early night. I guess I'll tackle this pain tomorrow.
31.07.2016, 9:00PM (Australia)








