From a067bd488fb1ad0ce4818c6601031554397c1d80 Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Tue, 21 Jun 2011 17:12:21 +0200 Subject: automatic commit for pwgen-2.03 --- pw_rand.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'pw_rand.c') diff --git a/pw_rand.c b/pw_rand.c index e49ff76..5c9cd4f 100644 --- a/pw_rand.c +++ b/pw_rand.c @@ -11,20 +11,16 @@ #include #include "pwgen.h" -#define FIRST_CHAR '!' -#define LAST_CHAR '~' - -static char bad_chars[] = "'\\\"!@#$%^&*()+=_-{}[]<>`~?:;,/.|"; +#define PW_CHARS "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" void pw_rand(char *buf, int size, int pw_flags) { - char ch; - int i = 0; + char ch, *chars = PW_CHARS; + int i = 0, len; + len = strlen(chars); while (i < size) { - ch = pw_random_number(LAST_CHAR - FIRST_CHAR) + FIRST_CHAR; - if (strchr(bad_chars, ch)) - continue; + ch = chars[pw_random_number(len)]; buf[i++] = ch; } buf[size] = 0; -- cgit v1.2.3