Utils/UI: Make GeneratePassword() use std::string

Just for consistency
This commit is contained in:
tt2468 2021-09-17 02:03:47 -07:00
parent a5a19b9952
commit 69ccc99921
4 changed files with 5 additions and 5 deletions

View File

@ -67,7 +67,7 @@ void Config::Load()
} else {
AuthRequired = config_get_bool(obsConfig, CONFIG_SECTION_NAME, PARAM_AUTHREQUIRED);
if (FirstLoad) {
ServerPassword = Utils::Crypto::GeneratePassword();
ServerPassword = QString::fromStdString(Utils::Crypto::GeneratePassword());
} else {
ServerPassword = config_get_string(obsConfig, CONFIG_SECTION_NAME, PARAM_PASSWORD);
}

View File

@ -244,7 +244,7 @@ void SettingsDialog::EnableAuthenticationCheckBoxChanged()
void SettingsDialog::GeneratePasswordButtonClicked()
{
QString newPassword = Utils::Crypto::GeneratePassword();
QString newPassword = QString::fromStdString(Utils::Crypto::GeneratePassword());
ui->serverPasswordLineEdit->setText(newPassword);
ui->serverPasswordLineEdit->selectAll();
passwordManuallyEdited = false;

View File

@ -59,13 +59,13 @@ bool Utils::Crypto::CheckAuthenticationString(std::string secret, std::string ch
return (authenticationString == expectedAuthenticationString);
}
QString Utils::Crypto::GeneratePassword(size_t length)
std::string Utils::Crypto::GeneratePassword(size_t length)
{
// Get OS random number generator
QRandomGenerator *rng = QRandomGenerator::system();
// Fill string with random alphanumeric
QString ret;
std::string ret;
for (size_t i = 0; i < length; i++)
ret += allowedChars[rng->bounded(0, allowedCharsCount)];

View File

@ -8,6 +8,6 @@ namespace Utils {
std::string GenerateSalt();
std::string GenerateSecret(std::string password, std::string salt);
bool CheckAuthenticationString(std::string secret, std::string challenge, std::string authenticationString);
QString GeneratePassword(size_t length = 16);
std::string GeneratePassword(size_t length = 16);
}
}