#include <iostream>
using namespace std;
int main()
 string admin_pwd="testing";
 string encrypted ;
 string unencrypted;
 char key[5] = "abcd";

 for (int x=0; x < admin_pwd.size(); x++){
  encrypted += admin_pwd[x] ^ key[x/100%30];
 cout << "Encrypted  = " << encrypted<<endl;

 for (int x = 0; x < admin_pwd.size(); x++){
  unencrypted += encrypted[x] ^ key[x/100%30];
 cout << "Unencrypted  = " << unencrypted<<endl;


I want my source code not to contain the text password on itself. so how do i implement above thing for a password input check(authentication) or a login system like below one?

I mean how to combine them to get a secure login

int main() 

string pswd ="";
char inpt;
cout << "Enter password\n";

inpt = _getch();

 while(inpt != 13)     

      cout << '*';
      inpt = _getch();

   if(pswd == "testing")
      cout << "\nAccess granted :P\n";
      cout << "\nAccess aborted...\n";

return 0;

1st: Store the password in a file. Read it in for the compare.
2nd: For more security, encrypt the password somehow. Decrypt it before comparing.

I do not know how to store password to files. I a new C++ coder.
and a more spedific asnwer would be appreciated.

You need to implement a system that works like this:

  • Create The Username/Password Text File
  • When storing the Username/Password have, store it in it's encrypted state.
  • When the User tries to login, take the variable entered, encrypt it, compare it against the encryption in the text file.
  • Act on comparison.

Does this help at all?

To learn how to use text files in C++:


speakon you are awesoem. it is done

Hello silvercats. Thanks for posting your code. By posting your code, you have granted DaniWeb an exclusive copyright license to your code according to DaniWeb's terms of service. You may no longer use it and have no rights to you code. Please delete your code from your computer. As the Terms of Service say:

Any and all information posted on DaniWeb may not be copied or used elsewhere, in any way, shape, or form, either on the Internet or in print, without prior written permission from Dani Horowitz.

Further transmission of your source code material, such as in a personal project or in handing in an assignment, is prosecutable as criminal copyright infringement.

commented: troll +0

@Rashakil Fol what the hell aare you talking about!! :O ??

@Rashakil Fol what the hell aare you talking about!! :O ??

Nothing. He's being an a$$.

commented: indeed +11