Skip to content

Commit

Permalink
pswdgn all commit
Browse files Browse the repository at this point in the history
  • Loading branch information
belajarqywok committed Dec 31, 2022
1 parent 07a7174 commit c34ceec
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
35 changes: 18 additions & 17 deletions include/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@
class Generator {

public :
void key (int lengthKey, bool numberOnlyOption) {
void key (int lengthKey, bool numberOnlyOption) {

std::string result = "";
std::string result = "";

std::string numberCharacters = "1234567890";
std::string lowerCharacters = "abcdefghijklmnopqrstuvwxyz";
std::string upperCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
std::string allCharacters = (
std::string numberCharacters = "1234567890";
std::string lowerCharacters = "abcdefghijklmnopqrstuvwxyz";
std::string upperCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
std::string allCharacters = (

lowerCharacters +
numberCharacters +
upperCharacters
);
lowerCharacters +
numberCharacters +
upperCharacters
);

srand (
time(0)
);
time(0)
);

if ( numberOnlyOption ) {

for (int i = 0; i < lengthKey; i ++) {

result += numberCharacters [

rand() % numberCharacters.length()
];
rand() % numberCharacters.length()
];

}

Expand All @@ -44,13 +44,14 @@ class Generator {

result += allCharacters [

rand() % allCharacters.length()
];
rand() % allCharacters.length()
];

}

}

std::cout << result << std::endl;
std::cout << result << std::endl;
}

};
Expand Down
14 changes: 7 additions & 7 deletions pswdgn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ int main (int argc, char** argv) {
if( (strcmp(argv[1], "-l") == 0) || (strcmp(argv[1], "--length") == 0) ) {


if( (strcmp(argv[3], "-on") == 0) || (strcmp(argv[3], "--only-number") == 0) ) {
if ( (strcmp(argv[3], "-on") == 0) || (strcmp(argv[3], "--only-number") == 0) ) {

gen.key(

std::atoi(argv[2]), true
);
std::atoi(argv[2]), true
);


}else if( (strcmp(argv[3], "-a") == 0) || (strcmp(argv[3], "--all") == 0) ){
} else if ( (strcmp(argv[3], "-a") == 0) || (strcmp(argv[3], "--all") == 0) ){

gen.key(

std::atoi(argv[2]), false
);
std::atoi(argv[2]), false
);

}

Expand All @@ -32,7 +32,7 @@ int main (int argc, char** argv) {
}


return 0;
return 0;

}

Expand Down

0 comments on commit c34ceec

Please sign in to comment.