Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Tutorial]Making a more flexible password protection - VB6

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Elec0
Expert Cheater
Reputation: 0

Joined: 21 Nov 2007
Posts: 188
Location: Out of my mind, back in five minutes.

PostPosted: Fri Dec 21, 2007 9:41 am    Post subject: [Tutorial]Making a more flexible password protection - VB6 Reply with quote

I thought that I might want to post this for people who don't know how to open, right to, close, and read from files.

----
For this tutorial I am assuming that you have a basic knowledge of VB6 and know some of the basics.


This is just a more fkexible way of getting and saving passwords than

Code:

If InputBox("Password:") = "Your Password Here" Then
     ' Code
Else
     'Code
End If


Writing to Text Files

While that may be fine for some people, it's not for me, so I decided to make a better way to retrieve and save passwords.
If you already know about how to open and manipulate files, you can skip this part, or you can review if you want.

To open a file, you use this nifty line of code:

Code:

Open "C:\Test.txt" for Output As #1


That opens the file for writing to, (The Output, we'll learn more about that later.) But, if you open the file and forget to close it, things screw up, so, let's fix it.

Code:

Open "C:\Test.txt" for Output As #1
... ' This means put your code here, but we don't have any code to put there yet, so just ignore it
Close #1


That will open and close the text file Test.txt in your C drive. But what good will a file do you that is only open for a nanosecond you ask? Well, not much, so you have to execute some code in that nanosecond.

To write to a file, you can use

Code:

Print #1, Text1.text


Or:

Code:

Write #1, Val(Text1.text), Val(Text2.text)


What the heck do these do you ask? Well, the Print statement writes text to a file, in this case the text in the textbox Text1.

The Write statement does the same thing, except that it can write multiple things to the same file.

So, to compile the things that we have learned so far into one place we would do this:

Code:

Open "C:\Text.txt" for Output As #1
Print #1, Text1.text
Close #1


Can you figure out what that would do? (If you can't I suggest you either quit programming altogether or go back and read about the Print statement again.) If you said 'It would write the text of Text1 to the file C:\Text.txt' then you are exactly right!

If you feel that you have that down, we can move on to getting text from a file, otherwise, feel free to go back and review and experiment until you feel comfortable with what we have covered so far.

Reading From Text Files

Now, to get text from text files is just a little bit different than writing to text files. You open the file in almost the same way, except you use the Input instead of the Output

Code:

Open "C:\Text.txt" for Input As #1


What Input does is allow you to read text instead of writing text, as with Output.

To write text to the file, you use the statement

Code:

Input #1, Text1.text


That will, as you have probably already figure out, write the text of file #1, (whatever that is) to the textbox Text1.

That was pretty easy right? Well, let's just squish all we know about reading from files into a couple lines of code

Code:

Open "C:\Test.txt" for Input As #1
Input #1, Text1.text
Close #1 ' You still have to close the file even when you are reading from it.


Easy right? Good.

Okay, time for review:

Q: What line of code do you use to open a file for writing to?
A:
Code:
Open "C:\Text.txt" for Output As #1


Q: What line of code do you use to read text out of a textbox?
A:
Code:
Input #1, Text1.text


Q: What line of code do you use to open a file for reading from?
A:
Code:
Open "C:\Text.txt" for Input As #1


So, how did you do on the quiz?

Now, the part you have all been waiting for,

Making a More Flexible Password

To make a more flexible password:

First, make a form with your password textbox and two command buttons. Then, in the command button, (which will simulate the register) you need to open your file that you want to store the passwords for writing to.
Then you need to write the text in your password textbox into the file.
After that, if all goes well, put in the login command button, the code to read from the file, and see if the text in the password textbox equals the text in the password text file.

If you have any problems, please post here or PM me, I will be glad to try and help you.

Also, if you found this tutorial helpful please say so.
If you see something that I have typed wrong or did wrong, please let me know.

~Elec0

_________________


Last edited by Elec0 on Fri Dec 21, 2007 11:57 am; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Dec 21, 2007 10:20 am    Post subject: Reply with quote

You know you aren't showing anything different here. You are reading an insecure password from a text file that anyone can open and take the password from. Following that you are still doing the if then check:

Elec0 wrote:
After that, if all goes well, put in the login command button, the code to read from the file, and see if the text in the password textbox equals the text in the password text file.


You never showed a method to prevent doing the if blah = blah type thing.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Elec0
Expert Cheater
Reputation: 0

Joined: 21 Nov 2007
Posts: 188
Location: Out of my mind, back in five minutes.

PostPosted: Fri Dec 21, 2007 10:24 am    Post subject: Reply with quote

Well, actually I suppose I could have called a more flexible password.
Although, the main reason I wrote the password part was to give people who didn't know how to manipulate files practice. It wasn't really for the password.

_________________
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Dec 21, 2007 10:47 am    Post subject: Reply with quote

Elec0 wrote:
Well, actually I suppose I could have called a more flexible password.
Although, the main reason I wrote the password part was to give people who didn't know how to manipulate files practice. It wasn't really for the password.


Then why did you name the topic what you did lol? Should rename it if you want it to be helpful for file manipulation.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Elec0
Expert Cheater
Reputation: 0

Joined: 21 Nov 2007
Posts: 188
Location: Out of my mind, back in five minutes.

PostPosted: Fri Dec 21, 2007 11:56 am    Post subject: Reply with quote

I might. I didn't think of it when I wrote it.

Okay, I changed it, it is now a more flexible password protection.

_________________
Back to top
View user's profile Send private message MSN Messenger
*Mario*
Expert Cheater
Reputation: 0

Joined: 06 Nov 2007
Posts: 106
Location: Ah... Don't look behind you.

PostPosted: Fri Dec 21, 2007 3:15 pm    Post subject: Reply with quote

I put full code and an example, you just put how to do text files.
So I dont think your thread is that neccesary. but oh well.

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites