Categories > Coding > C++ >
bad password generator in c++ (ported from c, then modified)
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
Cancel
Post
Replied
this made me feel better about my code
Cancel
Post
Did I mention I use arch btw?
Replied
this sht took me years to understnad how rand() works and i still dont understand it properly
Cancel
Post
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Comments
TERIHAX 30 Reputation
Commented
how tf else was i supposed to concat to a string
0
Whoman 17 Reputation
Commented
@TERIHAX No not that, its because its made with c++
0
TERIHAX 30 Reputation
Commented
@Whoman ah
/balls
0