aboutsummaryrefslogtreecommitdiffstats
path: root/src/utility/random.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utility/random.cpp')
-rw-r--r--src/utility/random.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/utility/random.cpp b/src/utility/random.cpp
index b2a935d8..cefaea3e 100644
--- a/src/utility/random.cpp
+++ b/src/utility/random.cpp
@@ -55,5 +55,25 @@ const unsigned int random::getProcess()
}
+const string random::getString(const int length, const string& randomChars)
+{
+ string res;
+ res.resize(length);
+
+ const unsigned int x = randomChars.length();
+ int c = 0;
+
+ while (c < length)
+ {
+ for (unsigned int n = random::getNext() ; n != 0 ; n /= x)
+ {
+ res[c++] = randomChars[n % x];
+ }
+ }
+
+ return (res);
+}
+
+
} // utility
} // vmime