Skip to content

Instantly share code, notes, and snippets.

Created May 4, 2012 23:15
Show Gist options
  • Select an option

  • Save anonymous/2598292 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/2598292 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist May 4, 2012.
    71 changes: 71 additions & 0 deletions gistfile1.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    //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;
    }
    }