Would this work, or would this make you have to set the password every time? I want to be able to save the password when the program is not in use. How would I go about doing that? Is there a way to make the program change the source code of the program?
1 2 3 4 5 6 7 8 9
string password;
cout << "Set the password";
cin >> password;
cout << "Enter the password";
cin >> password;
if (password == "(password user set earlier)"
{
(code)
}
ok, the code that you posted wouldent work because itd resets the password variable twice, to exspress the comparison between two passwords use this meathod:
1 2 3 4 5 6 7 8 9 10
string password1;
string password2;
cout << "set the password:\n";
cin >> password1;
cout<<"enter the password you intruter -_- :\n"
cin >> password2;
if(password1==password2)
{
cout << "hi not intruder ";
}
as for saving the password so that you can call the program a second time and it would already know the password. you should use fileIO functions to create a file somewhere and then get the password from that file and compare it to the entered password.search stdio.h in this site's c++ reference
Okay I fixed it by following what shaktar did almost exactly. I have 2 exes now. One that sets the password that you enter, and one that asks you for the password, then executes the code. Now I have to think up some really cool code.
JSYK, you should have a one-way function that hashes or encrypts the password, and store the hash/encryption, so that users can't just look at the password file...
When the user enters his password, just hash or encrypt it and compare the result with what is in the file.
What Duoas means is that you should encrypt your passwords. Encryption to my knowledge is when you make a different character for an other character. For instance lets say I have the password Weezer if I wanted to encrypt it I would have to make up characters for each Letter in the word "Weezer" so I could do something like this
! = W
% = E
# = R
^ = Z
So now Weezer looks like this !%%^%#
If you did not have the key then this makes no sense. So hackers can not get your password.
And do not think that you know nothing File I/O is not very easy. And you are getting it pretty fast.
Yay! I don't really know as little as I thought! And how would I go about actually doing the encryption process? And can someone look at the source code of my 2 projects to see if I can make any improvements?
File 1:
http://pastebin.com/j5YAzv1U
I know there is a lot of bad coding and I know for all the size_ts I could have just used one but I was getting confused using only one so I use one for every letter. I made this a long time ago so there might be bugs so please excuse me. Also there might be easier ways of doing this but I did not know better so again sorry. I also believe you can mess with the ASCII value but I do not know much about that.
300+ lines of code? The most i've EVER coded is the 27 lines I have here, and the SDL code that didn't work that was like 30 something. 300+ must have taken a LONG time
Is there a way to make multiple passwords, so that different users could get in to the program and resume their last session? I was thinking copying and pasting the code, renaming the variables, and making more text files. Wait...is it possible to have a program MAKE a text file, then let you set the password, then let you enter the program?