mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user