/* * Password Generator * by Shiv [ for the Phallic Enterprises ] * [01/30/1999] / [02/22/1999] - v1.0 * [09/20/1999] / [09/20/1999] - v2.0/2.5 * [11/25/2001] / [12/26/2001] - v3.0 * Multi-option password generator. */ #include #include #include #include numer(int &length); alphab_ncs(int &length); alphab_cs(int &length); alphanum_ncs(int &length); alphanum_cs(int &length); char alpha01[26] = {"abcdefghijklmnopqrstuvwxyz"}; char alpha02[26] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; int numeric[10]; int main() { int opt01, length, nlcv = 0; char opt02; for (nlcv = 0; nlcv < 10; nlcv++) //loads numeric numeric[nlcv] = nlcv; //array clrscr(); cout << "***Alphanumeric Password Generator***\n" << " by Shiv, for the Phallic Enterprises.\n\n"; cout << "What do you want your password " << "to be created with?\n" << "#1: all numbers.\n" << "#2: all letters.\n" << "#3: alphanumeric.\n" << "Please type a number. "; cin >> opt01; if (opt01 != 1) { cout << "Do you want it " << "to be case sensitive? [Y/N] "; cin >> opt02; opt02 = toupper(opt02); } else opt02 = 'X'; cout << "How many characters do you " << "want it to be? "; cin >> length; if (opt01 == 1) numer(length); else if ((opt01 == 2) && (opt02 == 'N')) alphab_ncs(length); else if ((opt01 == 2) && (opt02 == 'Y')) alphab_cs(length); else if ((opt01 == 3) && (opt02 == 'N')) alphanum_ncs(length); else if ((opt01 == 3) && (opt02 == 'Y')) alphanum_cs(length); cout << "\n\nHit enter to quit. "; getch(); return 0; } //******************************** //numerical password function numer(int &length) { int lcv, master; lcv = master = 0; randomize(); cout << "\n\nPassword: "; while (lcv != length) { master = random(10); cout << numeric[master]; lcv++; } return 0; } //******************************** //alphabetical password function (non case sensitive) alphab_ncs(int &length) { int lcv, master; lcv = master = 0; randomize(); cout << "\n\nPassword: "; while (lcv != length) { master = random(26); cout << alpha01[master]; lcv++; } return 0; } //******************************** //alphabetical password function (case sensitive) alphab_cs(int &length) { int lcv, master, control; lcv = master = control = 0; randomize(); cout << "\n\nPassword: "; while (lcv != length) { master = random(27); control = random(2); if (control == 1) cout << alpha01[master]; else cout << alpha02[master]; lcv++; } return 0; } //******************************** //alphanumerical password function (non-case sensitive) alphanum_ncs(int &length) { int lcv, numer, control, alpha; lcv = numer = control = alpha = 0; randomize(); cout << "\n\nPassword: "; while (lcv != length) { numer = random(10); alpha = random(25); control = random(2); if (control == 1) cout << numeric[numer]; else cout << alpha01[alpha]; lcv++; } return 0; } //******************************** //alphanumerical password function (case sensitive) alphanum_cs(int &length) { int lcv, numer, alpha, control; lcv = numer = control = alpha = 0; randomize(); cout << "\n\nPassword: "; while (lcv != length) { numer = random(11); alpha = random(27); control = random(3); if (control == 1) cout << numeric[numer]; else if (control == 2) cout << alpha01[alpha]; else cout << alpha02[alpha]; lcv++; } return 0; } //* ******************beginoutput****************** * //* ******************endoutput****************** * //phly the phallus [ members.tripod.com/~asmodaeus ]