From e46c5277334e7435b74eedba7fdfe2c773f48d06 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Tue, 17 Sep 2013 02:57:10 -0400 Subject: Accept hexadecimal and string values for seeds --- src/util/string.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/util/string.cpp') diff --git a/src/util/string.cpp b/src/util/string.cpp index 2c1dea497..a2312baf8 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "string.h" #include "pointer.h" +#include "numeric.h" #include "../sha1.h" #include "../base64.h" @@ -136,3 +137,18 @@ char *mystrtok_r(char *s, const char *sep, char **lasts) { *lasts = t; return s; } + +u64 read_seed(const char *str) { + char *endptr; + u64 num; + + if (str[0] == '0' && str[1] == 'x') + num = strtoull(str, &endptr, 16); + else + num = strtoull(str, &endptr, 10); + + if (*endptr) + num = murmur_hash_64_ua(str, (int)strlen(str), 0x1337); + + return num; +} -- cgit v1.2.3