make create_random_token() public, so it can be used to create a random session ID

old_session_management
Roker 3 years ago
parent 28aa49c365
commit 654917b214

@ -15,8 +15,10 @@ namespace
{
// 36 alphanumeric characters
static const char token_alphabet[] = "qaywsxedcrfvtgbzhnujmikolp1234567890POIUZTREWQASDFGHJKLMNBVCXY";
std::string create_random_token(unsigned length=38)
}
std::string create_random_token(unsigned length)
{
static std::random_device rd;
static std::mt19937 gen(rd());
@ -102,7 +104,6 @@ void write_security_file(const std::string& content)
#endif // ! _WIN32
} // end of anonymous namespace
namespace js = json_spirit;
@ -110,7 +111,7 @@ namespace js = json_spirit;
// creates a file with restrictive access rights that contains a security token.
std::string create_security_token(const std::string& server_address, unsigned port_nr, const std::string& path)
{
const std::string sec_token = create_random_token();
const std::string sec_token = create_random_token(38);
js::Object o;
o.emplace_back("address", server_address);

@ -3,6 +3,9 @@
#include <string>
std::string create_random_token(unsigned length=38);
// deletes the token file, if it exists
void remove_token_file();

Loading…
Cancel
Save