|
-
Nov 19th, 2006, 10:09 PM
#1
PowerPoster
Re: How to Store Username and Password
the best way to do this is to store the usernames and passwords into a database, then connect your vb6 app to the database. there are many threads on this already.
-
Nov 19th, 2006, 10:48 PM
#2
Re: How to Store Username and Password
You can create a database from Microsoft Access. Put two fields like "username" and "password".
Put this to your module
VB Code:
Option Explicit
Public cn As ADODB.Connection
'connection string from Microsoft Access
Public Sub OpenConnection()
Set cn = New ADODB.Connection
With cn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\yourdbase.mdb;Persist Security Info=False"
.CommandTimeout = 0
.CursorLocation = adUseClient
.Open
End With
End Sub
Put this to your form
VB Code:
Public rs As ADODB.Recordset
Private Sub Form_Load()
OpenConnection
End Sub
Private Sub Command1_Click()
Set rs = New ADODB.Recordset
strsearch = "SELECT username FROM tablename WHERE username like '" & Text1.Text & "'"
rs.Open strsearch, adoc, adOpenDynamic, adLockOptimistic
rs.Requery
If rs.RecordCount >= 1 Then
'put your conditions here
else
'your code here
end if
End Sub
This is just a sample. you can find much better codes out here.
-
Nov 20th, 2006, 02:04 PM
#3
Re: How to Store Username and Password
-
Nov 21st, 2006, 07:56 AM
#4
Thread Starter
New Member
Re: How to Store Username and Password
Thanks for the great info but i dont have microsoft access so it doesnt help me much. i also dont know how to link the two programs together to get the database from one to the other. if it is possible i would like to have the vb program self-contained. i would like the username and password saved all within the vb program.
-
Nov 21st, 2006, 08:21 AM
#5
Re: How to Store Username and Password
 Originally Posted by wryan_garner4
i would like the username and password saved all within the vb program.
I'm not sure what you mean by that ?
And about the link I posted, that example is using Access, but you can easily change it to whatever database you want. Just change the Connection String in the LoadDatabase function, and the SQL statements to match the database SQL type... though I think the SQL statements should be the same in any database...
Just remember that if the example is made for Access, it does not mean that this works ONLY in Access...
-
Nov 21st, 2006, 08:29 AM
#6
Member
Re: How to Store Username and Password
the data entered in the user name and password fields must be linked to a database so you can retrieve them later for validation.. add an adodc control and cofigure connection settings.
-
Nov 21st, 2006, 08:49 AM
#7
Re: How to Store Username and Password
You don't need to store them in a database although there's noting wrong with that. Another good way is to store the data in the Registry. If you store it there you should encrypt the password and also possibly the username.
-
Nov 21st, 2006, 02:43 PM
#8
New Member
Re: How to Store Username and Password
 Originally Posted by wryan_garner4
Thanks for the great info but i dont have microsoft access so it doesnt help me much. i also dont know how to link the two programs together to get the database from one to the other. if it is possible i would like to have the vb program self-contained. i would like the username and password saved all within the vb program.
I understand what you mean. You need to be very careful doing this, because anyone can trivially read the username and password back out of the file. However, if you need to store this, you can use a CRC32 hash to obfuscate the password. What you would do is generate a CRC32 hash of the password ahead of time, and store that in a module. At runtime, DON'T compare password to password, but rather hash the password that the user types in, and compare that to your stored hash.
It's not foolproof, in that specially crafted strings can generate the same CRC32, but it's significantly more complex to reverse engineer.
-
Nov 21st, 2006, 03:21 PM
#9
Re: How to Store Username and Password
 Originally Posted by insta
I understand what you mean. You need to be very careful doing this, because anyone can trivially read the username and password back out of the file. However, if you need to store this, you can use a CRC32 hash to obfuscate the password. What you would do is generate a CRC32 hash of the password ahead of time, and store that in a module. At runtime, DON'T compare password to password, but rather hash the password that the user types in, and compare that to your stored hash.
It's not foolproof, in that specially crafted strings can generate the same CRC32, but it's significantly more complex to reverse engineer.
That is exacly what I posted in Post #4, except I'm using MD5 to hash wich is 128 Bit
-
Nov 21st, 2006, 04:05 PM
#10
New Member
Re: How to Store Username and Password
 Originally Posted by CVMichael
That is exacly what I posted in Post #4, except I'm using MD5 to hash wich is 128 Bit
Apologies ... I was trying to provide a database-less solution. Although I guess I didn't actually include any code.
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
|