This commit is contained in:
tola
2023-05-06 23:27:52 +07:00
parent 0ed01fb1a1
commit 1f703d3c9d
2 changed files with 85 additions and 4 deletions
+77
View File
@@ -0,0 +1,77 @@
#ifndef C_COLORS_H
#define C_COLORS_H
// reset
#define RESET "\033[0m"
// regular colrs
#define GREEN "\033[0;32m" // GREEN
#define BLUE "\033[0;34m" // BLUE
#define YELLOW "\033[1;33m" // YELLOW
#define RED "\033[0;31m" // RED
#define BLACK "\033[0;30m" // BLACK
#define PURPLE "\033[0;35m" // PURPLE
#define CYAN "\033[0;36m" // CYAN
#define WHITE "\033[0;37m" // WHITE
// bold
#define BBLACK "\033[1;30m" // BLACK
#define BRED "\033[1;31m" // RED
#define BGREEN "\033[1;32m" // GREEN
#define BYELLOW "\033[1;33m" // YELLOW
#define BBLUE "\033[1;34m" // BLUE
#define BPURPLE "\033[1;35m" // PURPLE
#define BCYAN "\033[1;36m" // CYAN
#define BWHITE "\033[1;37m" // WHITE
// Underline
#define UBLACK "\033[4;30m" // BLACK
#define URED "\033[4;31m" // RED
#define UGREEN "\033[4;32m" // GREEN
#define UYELLOW "\033[4;33m" // YELLOW
#define UBLUE "\033[4;34m" // BLUE
#define UPURPLE "\033[4;35m" // PURPLE
#define UCYAN "\033[4;36m" // CYAN
#define UWHITE "\033[4;37m" // WHITE
// Background
#define ON_BLACK "\033[40m" // BLACK
#define ON_RED "\033[41m" // RED
#define ON_GREEN "\033[42m" // GREEN
#define ON_YELLOW "\033[43m" // YELLOW
#define ON_BLUE "\033[44m" // BLUE
#define ON_PURPLE "\033[45m" // PURPLE
#define ON_CYAN "\033[46m" // CYAN
#define ON_WHITE "\033[47m" // WHITE
// High Intensity
#define IBLACK "\033[0;90m" // BLACK
#define IRED "\033[0;91m" // RED
#define IGREEN "\033[0;92m" // GREEN
#define IYELLOW "\033[0;93m" // YELLOW
#define IBLUE "\033[0;94m" // BLUE
#define IPURPLE "\033[0;95m" // PURPLE
#define ICYAN "\033[0;96m" // CYAN
#define IWHITE "\033[0;97m" // WHITE
// Bold High Intensity
#define BIBLACK "\033[1;90m" // BLACK
#define BIRED "\033[1;91m" // RED
#define BIGREEN "\033[1;92m" // GREEN
#define BIYELLOW "\033[1;93m" // YELLOW
#define BIBLUE "\033[1;94m" // BLUE
#define BIPURPLE "\033[1;95m" // PURPLE
#define BICYAN "\033[1;96m" // CYAN
#define BIWHITE "\033[1;97m" // WHITE
// High Intensity backgrounds
#define ON_IBLACK "\033[0;100m" // BLACK
#define ON_IRED "\033[0;101m" // RED
#define ON_IGREEN "\033[0;102m" // GREEN
#define ON_IYELLOW "\033[0;103m" // YELLOW
#define ON_IBLUE "\033[0;104m" // BLUE
#define ON_IPURPLE "\033[0;105m" // PURPLE
#define ON_ICYAN "\033[0;106m" // CYAN
#define ON_IWHITE "\033[0;107m" // WHITE
#endif // C_COLORS_H
+8 -4
View File
@@ -7,6 +7,7 @@
// #include <fcntl.h>
// #include <stdint.h>
#include <string.h>
#include "colors.h"
#define ALPHABET "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM[]{}<>()*#"
#define HELP_MESSAGE "\tpwdgen <quantity> - generates a password of the given size from the standard alphabet\n"\
@@ -56,7 +57,7 @@ int main(int argc, char *argv[]) {
} else if (atoi(argv[1]) > 0) {
int quantity = atoi(argv[1]);
char *pwd = get_random_string(ALPHABET, quantity);
printf("Password -> %s\n", pwd);
printf("%sPassword %s->%s %s\n", GREEN, YELLOW, BIWHITE, pwd);
return 0;
} else if (atoi(argv[1]) == 0) {
// char *file_extension = get_file_extension(argv[1]);
@@ -85,7 +86,8 @@ int main(int argc, char *argv[]) {
// }
// printf("%s\n", get_file_extension(argv[1]));
char *pwd = get_random_string(argv[1], 4);
printf("Password -> %s\n", pwd);
// printf("Password -> %s\n", pwd);
printf("%sPassword %s->%s %s\n", GREEN, YELLOW, BIWHITE, pwd);
return 0;
}
}
@@ -93,11 +95,13 @@ int main(int argc, char *argv[]) {
int quantity = atoi(argv[2]);
char *alphabet = argv[1];
char *pwd = get_random_string(alphabet, quantity);
printf("Password -> %s\n", pwd);
// printf("Password -> %s\n", pwd);
printf("%sPassword %s->%s %s\n", GREEN, YELLOW, BIWHITE, pwd);
return 0;
}
char *pwd = get_random_string(ALPHABET, 4);
printf("Password -> %s\n", pwd);
// printf("Password -> %s\n", pwd);
printf("%sPassword %s->%s %s\n", GREEN, YELLOW, BIWHITE, pwd);
return 0;
}