aboutsummaryrefslogtreecommitdiff
path: root/pw_rand.c
diff options
context:
space:
mode:
authorPhilipp Klaus <philipp.klaus@gmail.com>2011-06-21 17:12:21 +0200
committerPhilipp Klaus <philipp.klaus@gmail.com>2011-06-21 17:12:21 +0200
commita067bd488fb1ad0ce4818c6601031554397c1d80 (patch)
tree7abf7fae76c0e77e17abaa83a2ca01030824661b /pw_rand.c
parent468a1f0c5bd165b6d0647b184885eb2040d7ddf4 (diff)
downloadpwgen-a067bd488fb1ad0ce4818c6601031554397c1d80.zip
automatic commit for pwgen-2.03
Diffstat (limited to 'pw_rand.c')
-rw-r--r--pw_rand.c14
1 files changed, 5 insertions, 9 deletions
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 <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;