From 4b059beb247a12726d9a471433a27a39190d583b Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 27 Sep 2013 20:07:07 -0400 Subject: Replace this silly random code generation code with something more sane looking --- src/misc.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/misc.cpp') diff --git a/src/misc.cpp b/src/misc.cpp index 76f666d28..33ac56bcd 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -749,3 +749,18 @@ Anope::string Anope::Resolve(const Anope::string &host, int type) return result; } +Anope::string Anope::Random(size_t len) +{ + char chars[] = { + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', + 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', + 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' + }; + Anope::string buf; + for (size_t i = 0; i < len; ++i) + buf.append(chars[rand() % sizeof(chars)]); + return buf; +} + -- cgit