summaryrefslogtreecommitdiff
path: root/src/misc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc.cpp')
-rw-r--r--src/misc.cpp15
1 files changed, 15 insertions, 0 deletions
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;
+}
+