Created
May 4, 2012 23:15
-
-
Save anonymous/2598292 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Name: Derrik Fleming | |
//Class: CS162 | |
//Prof: Karla Fant | |
#include <iostream> | |
using namespace std; | |
//Functions | |
void manager(); | |
void welcome(); | |
void obtainPass(char usrPass[]); | |
char passEncrypt(char usrPass[]); | |
//Constants | |
const int pSize = 100; | |
int main(){ | |
manager(); | |
return 0; | |
} | |
//Managing functions | |
void manager(){ | |
char usrPass[pSize]; | |
welcome(); | |
obtainPass(usrPass); | |
passEncrypt(usrPass); | |
} | |
//Welcome statement to user | |
void welcome(){ | |
cout << "Welcome. \nThis program is designed " | |
<< "to generate a password based on a user-" | |
<< "entered phrase\n\n\n" << endl; | |
return; | |
} | |
//Phrase to be read in | |
void obtainPass(char usrPass[]){ | |
char usrResp; | |
while (toupper(usrResp) != 'Y') { | |
cout << "Please enter a phrase, \n(Limit letters a-z &" | |
<< " A-Z, 100 characters max): "<< endl; | |
//User enters phrase | |
cin.get(usrPass, pSize, '\n'); | |
cin.ignore(100, '\n'); | |
cin.clear(); | |
//Echos for verification | |
cout << "Is this correct (Y/N)?: \n" << usrPass << endl; | |
cin >> usrResp; | |
} | |
return; | |
} | |
//Encryption of pass-phrase | |
char passEncrypt(char usrPass[]){ | |
char newPass[pSize]; | |
for (int i=0; i<pSize && usrPass[i] != '\0'; i++){ | |
char letter = usrPass[i]; | |
newPass[i] = letter; | |
int maxVal = strlen(usrPass); | |
if (maxVal >=0){ | |
newPass[i] = usrPass[(maxVal-1)-i]; | |
} | |
cout << newPass[i]; | |
return i; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment