summaryrefslogtreecommitdiffstats
path: root/lib/randstring.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/randstring.c')
-rw-r--r--lib/randstring.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/randstring.c b/lib/randstring.c
index 2eeed8f..dd5ca8f 100644
--- a/lib/randstring.c
+++ b/lib/randstring.c
@@ -1,12 +1,13 @@
#pragma once
+#include <time.h>
char *randstring(size_t length) {
static char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
char *randomString = NULL;
-
+ time_t t;
if (length) {
randomString = malloc(sizeof(char) * (length +1));
-
+ srand((unsigned) time(&t));
if (randomString) {
for (int n = 0;n < length;n++) {
int key = rand() % (int)(sizeof(charset) -1);