From 69ccc99921bd478464c857d2ff76fbe1eff940f9 Mon Sep 17 00:00:00 2001
From: tt2468 <tt2468@gmail.com>
Date: Fri, 17 Sep 2021 02:03:47 -0700
Subject: [PATCH] Utils/UI: Make GeneratePassword() use std::string

Just for consistency
---
 src/Config.cpp               | 2 +-
 src/forms/SettingsDialog.cpp | 2 +-
 src/utils/Crypto.cpp         | 4 ++--
 src/utils/Crypto.h           | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/Config.cpp b/src/Config.cpp
index b4316d29..d80ef378 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -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);
 		}
diff --git a/src/forms/SettingsDialog.cpp b/src/forms/SettingsDialog.cpp
index 7d504de1..3010476b 100644
--- a/src/forms/SettingsDialog.cpp
+++ b/src/forms/SettingsDialog.cpp
@@ -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;
diff --git a/src/utils/Crypto.cpp b/src/utils/Crypto.cpp
index 944b9603..27d22adb 100644
--- a/src/utils/Crypto.cpp
+++ b/src/utils/Crypto.cpp
@@ -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)];
 
diff --git a/src/utils/Crypto.h b/src/utils/Crypto.h
index a3d89a93..8851afb8 100644
--- a/src/utils/Crypto.h
+++ b/src/utils/Crypto.h
@@ -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);
 	}
 }