| Joined: Jul 2003 Posts: 6 Junior Member | Junior Member Joined: Jul 2003 Posts: 6 | im new to vb so pls dont critisize me.. anyway i dont know how to make a database.. i am trying to make a password protection program. I have the Account Name and Password text boxes and i need to make the database for the acc names and the passwords for the users... someone pls hlp... | | |
▼ Sponsored Links ▼
▲ Sponsored Links ▲
| | | Joined: Mar 2002 Posts: 1,273 DollarDNS Owner | DollarDNS Owner Joined: Mar 2002 Posts: 1,273 | The first question you need to ask yourself, is do you really NEED a database? It seems to me that if all you are gonna store is usernames and passwords, you should instead store usernames and passwords into a normal file and encrypt the information. Trust me, a user/pass file with encryption is easier than the database option.
So what will it be jack? database or file? | | | | Joined: Jul 2003 Posts: 6 Junior Member | Junior Member Joined: Jul 2003 Posts: 6 | Thanks for the info SR. Only problem is that I have no experiance on how to encrypt text in files. Oh and I think I will go with the normal file. Thanks again. | | | | Joined: Mar 2002 Posts: 1,273 DollarDNS Owner | DollarDNS Owner Joined: Mar 2002 Posts: 1,273 | second question. Do you want to use a secure encryption algorithm that already exists out there on the internet and is used for many things, or do you want to use a simple encoding algorithm which can be broken by even the more amateur of crackers (like myself)? | | | | Joined: Jul 2003 Posts: 6 Junior Member | Junior Member Joined: Jul 2003 Posts: 6 | What ever would be easiest until I learn the language. This is only a basic password form for my first program which will probably turn into trash lol. So I would probably have to say your second choice. | | | | Joined: Mar 2002 Posts: 1,273 DollarDNS Owner | DollarDNS Owner Joined: Mar 2002 Posts: 1,273 | Do you have any knowledge of file accessing in VB? | | | | Joined: Jul 2003 Posts: 6 Junior Member | Junior Member Joined: Jul 2003 Posts: 6 | I have very little knowledge of VB whatsoever. Sorry if I'm such an idiot when it comes to this but I'm starting to learn. | | | | Joined: Mar 2002 Posts: 1,273 DollarDNS Owner | DollarDNS Owner Joined: Mar 2002 Posts: 1,273 | Here's the code to an example of how to save and load files. You tell the SaveFile subroutine the path of the file you'd like to save to, and the contents you'd like to save into it. The LoadFile function returns the file contents specified in the path you gave it. On Error Resume Next line tells VB to stuff their errors where the sun don't shine so that it doesn't crash your program if a file doesn't exist or there's permission errors or something.
Copy SaveFile and LoadFile and use in your project. Tell me when you get this code working good in your program and then we'll get a simple encoding algorithm to prevent easy snooping of the information in the file. Unless you don't care of the contents of the file is readable.
Private Sub Form_Load() SaveFile "C:\example.txt", "hello" & vbcrlf & "bob" MsgBox LoadFile("C:\example.txt") End Sub
Private Sub SaveFile(Filename As String, Data As String) On Error Resume Next Open Filename For Output As #1 Print #1, Data; Close #1 End Sub
Private Function LoadFile(Filename As String) As String On Error Resume Next Open Filename For Input As #1 LoadFile = Input(LOF(1), #1) Close #1 End Function | | | | Joined: Jul 2003 Posts: 6 Junior Member | Junior Member Joined: Jul 2003 Posts: 6 | Thanks SR but I'm having some troubles understanding this. How would I set it so that the program would load usernames and passwords from a text file? Also after that I will need help on simple encryption of the passwords and usernames that are in this text file. I'm sorry if I am causing any frustration to you and thank you very much for taking your time to help me. | | | | Joined: Mar 2002 Posts: 1,273 DollarDNS Owner | DollarDNS Owner Joined: Mar 2002 Posts: 1,273 | You know what? Screw it. Let's go the INI file route cause it's easier. Add the following 2 lines to the top of your form code:
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Sub Form_Load() SaveUser "John", "Doe" MsgBox GetPass("John") End Sub
Use the following 2 routines
Private Sub SaveUser(User As String, Pass As String) WritePrivateProfileString "userlist", User, Pass, App.Path & "\users.ini" End Sub
Private Function GetPass(User As String) As String Dim Pass As String * 255, PassLength As Long PassLength = GetPrivateProfileString("userlist", User, "", Pass, 255, App.Path & "\users.ini") If PassLength > 0 Then GetPass = Left(Pass, PassLength) End Function
Tell me if you can't figure out how to use this. The code above is all you need to know to save/load user information. Then comes the encoding. | | |
Forums41 Topics33,840 Posts68,858 Members2,176 | Most Online3,253 Jan 13th, 2020 | | | |