Jump to content


[vb2010] Db encryption process help?

access database visual basic 2010 password encryption

  • Please log in to reply
2 replies to this topic

#1 megmut


    Resident One Post Wonder

  • Joined: 19-April 12

Posted 19 April 2012 - 11:37

Hey guys, this is my first post so sorry if this is the wrong forum but im pretty sure im in the right place. I dont usually ask in forums because someone else where has already asked it but i have searched and searched and cannot find an answer that i am looking for.

In a nutshell, i have a very basic login form which is connected to a database [access 2003] and uses IF statements to match the username and passwords. here is the code :

Imports System.Data.OleDb
Public Class LoginForm1

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source = C:\Users\Admin\Desktop\Login\database.mdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT username,password FROM table1 where username=? and password=?", con)
cmd.Parameters.AddWithValue("username", UsernameTextBox.Text)
cmd.Parameters.AddWithValue("password", PasswordTextBox.Text)
Dim read As OleDbDataReader = cmd.ExecuteReader()
If read.HasRows Then
If UsernameTextBox.Text = read.Item("username").ToString And PasswordTextBox.Text = read.Item("password").ToString Then
Label1.Text = read.Item("password").ToString
MsgBox("Login unsuccessful, username and passwords are case sensitive")
End If
MsgBox("Login unsuccessful")
End If
Catch ex As Exception
End Try
End Sub

Now, this all works handy dandy which i was fairly chuffed at. then i thought, i might as well go all the way and encrypt it. so the plan was..

user = admin
password = 8 (inside the database) however the user chose the password 4.
when back in vb, the user enters : admin ; 4 and the program uses
"if usernametextbox.text = admin and (val(passwordtextbox.text) * 2) then form2.show

so before i go doing 128bit encryption or anything stupid.. i litrally just want to get something as simple as a multiplication password before anything more complex...

Please help me, i already have tuffs of hair missing :(

Thanks in advance and i apologise if i have not explained very well, i know what i want.. but not how to describe it :/

#2 htcz


    Neowinian Senior

  • Joined: 22-July 11

Posted 19 April 2012 - 11:40

Basically this is what you want:


#3 Kami-


    ♫ d(-_-)b ♫

  • Tech Issues Solved: 3
  • Joined: 28-July 08
  • Location: SandBox

Posted 20 April 2012 - 04:09

Assuming you're using .NET there are built in libraries for this...