#include <iostream>
#include<string>
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;

system("pause");
}

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)     

      {
      pswd.push_back(inpt);
      cout << '*';
      inpt = _getch();
      }

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



system("pause");
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++:

http://www.cplusplus.com/doc/tutorial/files/

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.

Comments
troll

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

Nothing. He's being an a$$.

Edited 4 Years Ago by WaltP

Comments
indeed
This question has already been answered. Start a new discussion instead.