I am stupid:
How do I make a password protected file?
I am stupid:
How do I make a password protected file?
>How do I make a password protected file?
There are many ways, but we need to know what type of protection your looking for.....
It's just too vague, are you looking for code that the user would have to enter in a password to continue in the program?
Or are you looking for a utility that actually encrypts your program and decrypts it when the right password is input'd(this the right word?), something along those lines?
Your question is too vague sorry, can't exactly answer that without more information.
OS: Windows XP Pro CE
IDE: VS .NET 2002
Preferred Language: C++.
Umm...the first one, where you have to enter a password to continue and see the other stuff.
If you're talking about writing a password-protected program, it's as easy as:
Code:std::string password; //A string to hold the input std::cout << "Enter password: "; //Ask for the password std::getline(std::cin, password); //Let them type a password if(password != "my_password") //Check if they got it right { std::cout << "You got the wrong password!"; return 0; //If they got the password wrong, quit. }
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
Try this
Code:#include <iostream> #include <string> int main() { cout<<"Enter password: "; cin>>password; cin.ignore(); if ( password == "mypassword" ) { cout<<"Password correct!"; cin.get(); } else { cout<<"Sorry password incorrect, Quitting"; } }
A better method would be:
1) Get password
2) Apply encryption scheme (MD5 works)
3) Check it against password that already has been encrypted
themethod suffers one huge problem. I can open your executable with pretty much any text editor and see the password.Code:if (password == "mypassword")
>Try this
Too bad it won't work and has nothing to do with password protecting a file.
My best code is written with the delete key.
Well sorry, i'm just trying to help. You don't need to get so uptight at me!
>You don't need to get so uptight at me!
You need to chill out a bit. I wasn't trying to slam you down.
>Well sorry, i'm just trying to help.
If you don't post working code, you're not helping. Start by compiling and testing everything you post until you're confident that you can write correct code off the top of your head. It saves you the headache of people constantly correcting you, and it also saves you the headache of confusing the very people you're trying to help.
My best code is written with the delete key.
Judging from "I am stupid:"A better method would be:
1) Get password
2) Apply encryption scheme (MD5 works)
3) Check it against password that already has been encrypted
It sounds like that might be a little over his head
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
I made this with correct syntax, but for some reason DEV gave me trouble when trying to copy / paste so I typed this. I was careful, but if it does not work like I typed it above I have made a typing mistake. This is what I would do, but for the record, I have only started learning to code 2 days ago. Although people could just pop it open with a program editor, most people have no idea about that. Here's my work. If you don't like it, don't use it. It works for me.Code:#include <iostream> using namespace std; int main() { float a_a, b_b; b_b = 123 //replace 123 with password cout<<"Please enter your password: \n"; cin>> a_a; cin.ignore(); if ( a_a == b_b ) { cout<<"Correct.\n"; cin.get(); } else if ( a_a != b_b ) { cout<<"Incorrect.\n"; cin.get(); } }
The problem with that password is that you can only have numbers
Sorry....as I said, I just starting learning C++ 2 days ago. I tried for a very long time, but couldn't get anything else to work .Sorry, that's the best I can do as a newbie programmer.