Make CString::RandomString() produce something more random

Instead of A-Z we now use A-Z,a-z,0-9,!?.,:;/*-+()
This means our random strings are now 2.5 times more random :).


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1047 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-05-10 06:46:53 +00:00
parent dde7921e6c
commit ac2dc42f18

View File

@@ -662,10 +662,16 @@ CString CString::Format(const CString& sFormatStr, ...) {
}
CString CString::RandomString(unsigned int uLength) {
const char chars[] = "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789!?.,:;/*-+_()";
const size_t len = sizeof(chars) / sizeof(char);
size_t p;
CString sRet;
for (unsigned int a = 0; a < uLength; a++) {
sRet += (char) (rand() % 26) + 65;
p = (size_t) (len * (rand() / (RAND_MAX + 1.0)));
sRet += chars[p];
}
return sRet;