summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/md5calc.c10
-rw-r--r--src/common/md5calc.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/src/common/md5calc.c b/src/common/md5calc.c
index d6a38b865..2178739d6 100644
--- a/src/common/md5calc.c
+++ b/src/common/md5calc.c
@@ -9,6 +9,7 @@
#include "md5calc.h"
#include <string.h>
#include <stdio.h>
+#include <stdlib.h>
#ifndef UINT_MAX
#define UINT_MAX 4294967295U
@@ -227,3 +228,12 @@ void MD5_String(const char * string, char * output)
digest[ 8], digest[ 9], digest[10], digest[11],
digest[12], digest[13], digest[14], digest[15]);
}
+
+/** output is a sequence of non-zero characters to be used as password salt. */
+void MD5_Salt(unsigned int len, char * output)
+{
+ unsigned int i;
+ for( i = 0; i < len; ++i )
+ output[i] = (char)(1 + rand() % 255);
+
+}
diff --git a/src/common/md5calc.h b/src/common/md5calc.h
index e35e64219..323affa2c 100644
--- a/src/common/md5calc.h
+++ b/src/common/md5calc.h
@@ -3,5 +3,6 @@
void MD5_String(const char * string, char * output);
void MD5_Binary(const char * string, unsigned char * output);
+void MD5_Salt(unsigned int len, char * output);
#endif /* _MD5CALC_H_ */