This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 28th, 2012  |  syntax: C++  |  size: 1.01 KB  |  views: 55  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. };
clone this paste RAW Paste Data