diff options
| author | Philipp Klaus <philipp.klaus@gmail.com> | 2011-06-21 17:12:21 +0200 |
|---|---|---|
| committer | Philipp Klaus <philipp.klaus@gmail.com> | 2011-06-21 17:12:21 +0200 |
| commit | a067bd488fb1ad0ce4818c6601031554397c1d80 (patch) | |
| tree | 7abf7fae76c0e77e17abaa83a2ca01030824661b /pw_rand.c | |
| parent | 468a1f0c5bd165b6d0647b184885eb2040d7ddf4 (diff) | |
| download | pwgen-a067bd488fb1ad0ce4818c6601031554397c1d80.zip | |
automatic commit for pwgen-2.03
Diffstat (limited to 'pw_rand.c')
| -rw-r--r-- | pw_rand.c | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -11,20 +11,16 @@ #include <string.h> #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; |