Categories > Coding > C++ >

bad password generator in c++ (ported from c, then modified)

TERIHAX

i say im gay as a joke 🙀

Posts: 2239

Threads: 102

Joined: Jul, 2020

Reputation: 32

Posted

so this is part of my journey of learning cpp and i made a sh*tty password gen

 

#include <iostream>
#include <string>
#include <Windows.h>
#include <time.h>

using std::cout;
using std::cin;
using std::string;

int main()
{
    // uh this only works in windows i think idfk how to do for mac or linux
    SetConsoleTitleA("Sh*tty Password Gen in c++");

    string charSet = "abcdefghijklmnopqrstuvwxyz";
    int passLength;
    int uppercase = 1;
    int numbers = 1;
    int symbols = 1;

    cout << "sh*tty password gen made in c++\n\nhow many characters do you want the password to be:\n";
    cin >> passLength;

    cout << "\nuppercase characters?\n0: no\n1: uh yes\n";
    cin >> uppercase;

    cout << "\nnumbers?\n0: uh no\n1: yes\n";
    cin >> numbers;

    cout << "\nsymbols?\n0: uh no\n1: yes\n";
    cin >> symbols;

    printf("\nresults:\n");
    if (uppercase >= 1) {
        charSet += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

        cout << "uppercase letters: uh yes\n";
    }

    if (numbers >= 1) {
        charSet += "0123456789";

        cout << "numbers: uh yes\n";
    }

    if (symbols >= 1) {
        charSet += "~!@#$%^&*()-=_+`|\\[]{}:\"'<>,.?/";

        cout << "symbols: yes i think\n\ngenerated password:\n";
    }

    srand(time(nullptr));

    string password;
    auto charSetLength = (int)charSet.length();
    for (int i = 0; i < passLength; i++) {
        // uh apparently rand() has limited randomness idfk what that means
        password += charSet[rand() % charSetLength];
    }

    cout << password << "\n\n----------\n\nPress ctrl + c or any key along with enter to exit";

    float disposeVar;
    cin >> disposeVar;

    return 0;
}

 

my bad for the really bad code

 

https://streamable.com/xucpt5

 

repo:

https://github.com/TERIHAX/Sh_ttyCPPPasswordGen

 

download:

https://github.com/TERIHAX/Sh_ttyCPPPasswordGen/releases/download/1.2FIX/Sh_ttyPasswordGen.exe

  • 0

Posts: 531

Threads: 20

Joined: Nov, 2022

Reputation: 44

Replied

This is so bad it's good 

Comments

TERIHAX 32 Reputation

Commented

whats that supposed to mean

  • 0

Alawrpar 44 Reputation

Commented

@TERIHAX, it means its bad code

  • 0

TERIHAX 32 Reputation

Commented

  • 0

  • 0

https://cdn.discordapp.com/attachments/1136067487847415848/1146449877660872785/image.png

https://cdn.discordapp.com/attachments/1098921594249814066/1112144294007029932/WRDBanner_Alawapr_1.png

Posts: 1430

Threads: 71

Joined: May, 2022

Reputation: 20

Replied

this made me feel better about my code

Comments

TERIHAX 32 Reputation

Commented

how tf else was i supposed to concat to a string

  • 0

Whoman 20 Reputation

Commented

@TERIHAX No not that, its because its made with c++

  • 0

TERIHAX 32 Reputation

Commented

@Whoman ah

 

/balls

  • 0

  • 0

i use arch btw

TERIHAX

i say im gay as a joke 🙀

Posts: 2239

Threads: 102

Joined: Jul, 2020

Reputation: 32

Replied

this sht took me years to understnad how rand() works and i still dont understand it properly

  • 0

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )