Adblock breaks this site

[TUT] C# How to add a Basic Password to Programs

Discussion in 'Programming General' started by Fallen Soul, Jul 15, 2008.

  1. Fallen Soul

    Fallen Soul Apprentice

    Joined:
    Mar 11, 2007
    Posts:
    746
    Referrals:
    0
    Sythe Gold:
    0
    [TUT] C# How to add a Basic Password to Programs

    Well in this tutorial I will teach you how to use an "if statement" to make a very very basic password for your programs.

    To start open up your Visual studio and Click Create New Project > Windows form application (Name it what ever you want)
    [​IMG]

    Go to your toolbox and add a button, and a textbox to your form.
    [​IMG]

    Double click on your button and it should open up and look like this.
    [​IMG]

    Now add this code...

    Code:
    if (textBox1.Text == ("Jaghax"))
    {
     MessageBox.Show("Correct!");
    }
    This is simply telling your program that if the word "Jaghax" is entered into your textbox , then it should show you the Messagebox.

    So far this is what you should have and what it should look like.
    [​IMG]


    Push the start button at the top, or go to Debug > Start debugging
    [​IMG]

    Something like this should popup depending on where you put your buttons and if you named them.

    [​IMG]
    Notice, if you put anything else into the textbox it does nothing. That's cause we haven't told it what to do if something else is put there.

    Now we need to tell our program what to do if some one gets the password wrong.


    Now we need to tell our program to to do if something else is put in the textbox
    Add this right below the last "}" in the "if statement"

    Code:
    else
    {
     Application.Exit();
    }
    This is telling your program to close itself if anything other word is in the textbox other then your set password

    It should now look like this
    [​IMG]

    Now open your project again and type in a different word, other then "Jaghax". If you did it right it should instantly close.

    This is the end of my tutorial, thank you for reading and if you have any questions or advice please feel free to post it. (I made this myself and I posted it on a different site but felt that it should be released here as well)
     
  2. Chase Young

    Chase Young Guest

    Referrals:
    3
    [TUT] C# How to add a Basic Password to Programs

    Nice tutorial, I'm sure people will find it useful as I have. =)
     
  3. Fallen Soul

    Fallen Soul Apprentice

    Joined:
    Mar 11, 2007
    Posts:
    746
    Referrals:
    0
    Sythe Gold:
    0
    [TUT] C# How to add a Basic Password to Programs

    Thanks

    I have been gone for awhile. I will write some more tuts in C# if you like.
     
  4. Swan

    Swan When They Cry...
    Retired Global Moderator

    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner
    [TUT] C# How to add a Basic Password to Programs

    No encryption? No obfuscation?

    Easy way to crack this. Open it up in a debugger, search for all referrenced text strings - and there you go ;)
     
  5. Fallen Soul

    Fallen Soul Apprentice

    Joined:
    Mar 11, 2007
    Posts:
    746
    Referrals:
    0
    Sythe Gold:
    0
    [TUT] C# How to add a Basic Password to Programs

    Yeah but its supposed to be Basic. Its meant more for learning on how to use basic text boxes. Not meant to be used to hide your bank statements ;)

    Its also more of an If statement guide then anything.
     
  6. x⁹

    x⁹ Guest

    Referrals:
    1
    [TUT] C# How to add a Basic Password to Programs

    If you're going to use something that basic, you should AT LEAST store the password as an md5 hash....
     
  7. FartKnocker

    FartKnocker Forum Addict

    Joined:
    Sep 3, 2007
    Posts:
    285
    Referrals:
    0
    Sythe Gold:
    5
    [TUT] C# How to add a Basic Password to Programs

    Nice. not super secure but it's useful ^^.

    EDIT: How would I make it if the password is correct, it opens another form file?
     
  8. x⁹

    x⁹ Guest

    Referrals:
    1
    [TUT] C# How to add a Basic Password to Programs

    use form.show() or form.showDialog()
     
  9. FartKnocker

    FartKnocker Forum Addict

    Joined:
    Sep 3, 2007
    Posts:
    285
    Referrals:
    0
    Sythe Gold:
    5
    [TUT] C# How to add a Basic Password to Programs

    Thank you :idea: .
     
  10. gaddiel14

    gaddiel14 Newcomer

    Joined:
    Dec 12, 2009
    Posts:
    1
    Referrals:
    0
    Sythe Gold:
    0
    [TUT] C# How to add a Basic Password to Programs

    Thanks for the tips...../ it helps me lot.....


    __________________
    Chase Auto Loan
     
  11. Supah Fly

    Supah Fly Active Member
    Banned

    Joined:
    Aug 22, 2007
    Posts:
    202
    Referrals:
    1
    Sythe Gold:
    0
    [TUT] C# How to add a Basic Password to Programs

    or use .net reflector and find the password.
     
< Java Form | VB Tutorial set: 1. Introduction >


 
 
Adblock breaks this site