From a2015eefbf85403b547f0018a13596bf7c30d164 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Sun, 4 Jul 2021 17:34:37 +0000 Subject: routines: use new allowed chars to generate a password --- src/routines.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/routines.c b/src/routines.c index f6b6bcc..7a434f7 100644 --- a/src/routines.c +++ b/src/routines.c @@ -34,6 +34,8 @@ #include "r-x11.h" #endif +#define NUMBER_ALLOWED_CHARS (10+26+26+8) + int copy_outside(char *password) { #if defined(DISPLAY) @@ -169,12 +171,17 @@ char *get_input(int minlen, int maxlen) char *gen_password(int length) { - int i, min = 33, max = 126; + int i; + char allowed_chars[NUMBER_ALLOWED_CHARS] = + "abcdefghijklmnoqprstuvwyzx" + "ABCDEFGHIJKLMNOQPRSTUYWVZX" + "0123456789" + "!@#$^&*?"; char *password = malloc(sizeof(char) * (length + 1)); srand(time(NULL)); for(i = 0; i < length; i++) - password[i] = min + rand() % (max-min); + password[i] = allowed_chars[rand() % NUMBER_ALLOWED_CHARS]; return password; } -- cgit v1.2.3-18-g5258