1
0
mirror of https://github.com/anope/anope.git synced 2026-07-04 02:23:12 +02:00

Replace this silly random code generation code with something more sane looking

This commit is contained in:
Adam
2013-09-27 20:07:07 -04:00
parent b319fb089c
commit 4b059beb24
5 changed files with 24 additions and 36 deletions
+15
View File
@@ -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;
}