
Untitled
By: a guest on
Feb 28th, 2012 | syntax:
C++ | size: 1.01 KB | hits: 49 | expires: Never
void fWrite(string strEncrypted);
string fRetrieve();
string fEncrypt(string strInput);
void main()
{
string TEMP;
string strEncrypted;
string strInput;
cin >> strInput;
strEncrypted = fEncrypt(strInput);
cout << strEncrypted << endl;
fWrite(strEncrypted);
TEMP = fRetrieve();
cin >> TEMP;
return;
};
string fEncrypt(string strInput)
{
int nLen = (strInput.length());
for(int nPos = 0; nPos < nLen; nPos++)
{
strInput[nPos]=(((strInput[nPos])+(nPos+1))*2);
};
return strInput;
};
void fWrite(string strWrite)
{
ofstream filePassword;
filePassword.open("password.txt");
filePassword << strWrite;
filePassword.close();
return;
};
string fRetrieve()
{
string strPassword;
ifstream filePassword("password.txt");
filePassword >> strPassword;
//Decrypt the string
int nLen = (strPassword.length());
for(int nPos = 0; nPos < nLen; nPos++)
{
strPassword[nPos]=(((strPassword[nPos])-(nPos+1))/2);
};
cout << strPassword;
return strPassword;
};