private static string getSQPassword() { if (!String.IsNullOrEmpty(Properties.Settings.Default.ts3SQPW) && !String.IsNullOrEmpty(Properties.Settings.Default.keyTS) && !String.IsNullOrEmpty(Properties.Settings.Default.IVTS)) { try { using (RijndaelManaged aesDecryptTS = new RijndaelManaged()) { aesDecryptTS.Key = Convert.FromBase64String(Properties.Settings.Default.keyTS); aesDecryptTS.IV = Convert.FromBase64String(Properties.Settings.Default.IVTS); byte[] encrypted = Convert.FromBase64String(Properties.Settings.Default.ts3SQPW); return(PasswordStorage.DecryptStringFromBytes(encrypted, aesDecryptTS.Key, aesDecryptTS.IV)); } } catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); string message = $"ERROR: Couldn't decrypt ServerQuery password. Make sure you save the config first!\n\nINFO: {ex.Message} \n\nSRC: {ex.Source}"; string cap = "Error"; errorMSG(message, cap); return(""); } } else { return(""); } }
internal static string decryptRcon() { if (!String.IsNullOrEmpty(Properties.Settings.Default.key) && !String.IsNullOrEmpty(Properties.Settings.Default.IV) && !String.IsNullOrEmpty(Properties.Settings.Default.rconPW)) { try { using (RijndaelManaged aesDecrypt = new RijndaelManaged()) { aesDecrypt.Key = Convert.FromBase64String(Properties.Settings.Default.key); aesDecrypt.IV = Convert.FromBase64String(Properties.Settings.Default.IV); byte[] encrypted = Convert.FromBase64String(Properties.Settings.Default.rconPW); return(PasswordStorage.DecryptStringFromBytes(encrypted, aesDecrypt.Key, aesDecrypt.IV)); } } catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); string message = $"Error attempting to decrypt RCON Info. \n\nINFO: {ex.Message} \n\nSRC: {ex.Source}"; string cap = "Error"; MessageBoxIcon icon = MessageBoxIcon.Error; MessageBoxButtons btn = MessageBoxButtons.OK; MessageBox.Show(message, cap, btn, icon); return(""); } } return(null); }