diff options
Diffstat (limited to 'src/implementation.c')
-rw-r--r-- | src/implementation.c | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/implementation.c b/src/implementation.c index 7d19282..d2f71ea 100644 --- a/src/implementation.c +++ b/src/implementation.c @@ -205,28 +205,14 @@ int userEnterPassword(int minlen, int maxlen, char *path_insert, int flag_echo, return rvalue; } -char *generatePassword(char *dest, int amount, int max_len) +char *generatePassword(char *dest, int amount) { - char allowed_symbols[] = { - 'A','E','I','J','O','U','B','C','D','F','G','H', - 'K','L','M','N','P','Q','R','S','T','V','W','X', - 'Y','Z','a','e','i','j','o','u','b','c','d','f', - 'g','h','k','l','m','n','p','q','r','s','t','v', - 'w','x','y','z','1','2','3','4','5','6','7','8', - '9','0','!','#','$',';','%','^',':','&','?','*', - '(',')','-','_','+','=','<', '>' - }; - int max = sizeof(allowed_symbols); - srand(time(NULL)); - - char password[max_len]; - for(int i=0; i < amount; i++) - { - char c = allowed_symbols[rand() % max]; + int i, min = 33, max = 126; + char password[amount]; - password[i] = c; - password[i+1] = '\0'; - } + srand(time(NULL)); + for(i = 0; i < amount; i++) + password[i] = min + rand() % (max-min); strcpy(dest, password); return dest; |