aboutsummaryrefslogtreecommitdiffstats
path: root/src/routines.c
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-07-04 17:34:37 +0000
committerJoursoir <chat@joursoir.net>2021-07-04 17:34:37 +0000
commita2015eefbf85403b547f0018a13596bf7c30d164 (patch)
treed690ea7062368b9cc47ebc68bd055cb7426ce881 /src/routines.c
parentf173590a050875177f13f8dac2c02a68fa856752 (diff)
downloadlock-password-a2015eefbf85403b547f0018a13596bf7c30d164.tar.gz
lock-password-a2015eefbf85403b547f0018a13596bf7c30d164.tar.bz2
lock-password-a2015eefbf85403b547f0018a13596bf7c30d164.zip
routines: use new allowed chars to generate a password
Diffstat (limited to 'src/routines.c')
-rw-r--r--src/routines.c11
1 files 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;
}