str.pop_back(); // pop the extra \0
return str;
}
+
+void gen_rand_numeric(CephContext *cct, char *dest, size_t size) /* size should be the required string size + 1 */
+{
+ static constexpr char table[] = "0123456789";
+ choose_from(cct->random(), table, dest, size-1);
+ dest[size-1] = 0;
+}
+
+std::string gen_rand_numeric(CephContext *cct, size_t size)
+{
+ std::string str;
+ str.resize(size + 1);
+ gen_rand_numeric(cct, str.data(), str.size());
+ str.pop_back(); // pop the extra \0
+ return str;
+}
void gen_rand_alphanumeric_upper(CephContext *cct, char *dest, size_t size);
void gen_rand_alphanumeric_no_underscore(CephContext *cct, char *dest, size_t size);
void gen_rand_alphanumeric_plain(CephContext *cct, char *dest, size_t size);
+void gen_rand_numeric(CephContext *cct, char *dest, size_t size);
// returns a std::string with 'size' random characters
std::string gen_rand_alphanumeric(CephContext *cct, size_t size);
std::string gen_rand_alphanumeric_upper(CephContext *cct, size_t size);
std::string gen_rand_alphanumeric_no_underscore(CephContext *cct, size_t size);
std::string gen_rand_alphanumeric_plain(CephContext *cct, size_t size);
+std::string gen_rand_numeric(CephContext *cct, size_t size);