Advertisement
Guest User

Untitled

a guest
Feb 28th, 2012
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. void fWrite(string strEncrypted);
  2. string fRetrieve();
  3. string fEncrypt(string strInput);
  4.  
  5. void main()
  6. {
  7.     string TEMP;
  8.     string strEncrypted;
  9.     string strInput;
  10.     cin >> strInput;
  11.     strEncrypted = fEncrypt(strInput);
  12.     cout << strEncrypted << endl;
  13.     fWrite(strEncrypted);
  14.     TEMP = fRetrieve();
  15.    
  16.     cin >> TEMP;
  17.     return;
  18. };
  19.  
  20. string fEncrypt(string strInput)
  21. {
  22.     int nLen = (strInput.length());
  23.     for(int nPos = 0; nPos < nLen; nPos++)
  24.     {
  25.         strInput[nPos]=(((strInput[nPos])+(nPos+1))*2);
  26.     };
  27.     return strInput;
  28. };
  29.  
  30. void fWrite(string strWrite)
  31. {
  32.     ofstream filePassword;
  33.     filePassword.open("password.txt");
  34.     filePassword << strWrite;
  35.     filePassword.close();
  36.  
  37.     return;
  38. };
  39.  
  40. string fRetrieve()
  41. {
  42.     string strPassword;
  43.     ifstream filePassword("password.txt");
  44.     filePassword >> strPassword;
  45.  
  46.     //Decrypt the string
  47.     int nLen = (strPassword.length());
  48.     for(int nPos = 0; nPos < nLen; nPos++)
  49.     {
  50.         strPassword[nPos]=(((strPassword[nPos])-(nPos+1))/2);
  51.     };
  52.  
  53.     cout << strPassword;
  54.     return strPassword;
  55. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement