From afcb3af13cf6c33158ac5f93daf168d58e559e39 Mon Sep 17 00:00:00 2001 From: Bitl Date: Fri, 3 Sep 2021 10:19:42 -0700 Subject: [PATCH] important --- .../StorageAndFunctions/SecurityFuncs.cs | 49 ++++++++++++++++++- Novetus/NovetusLauncher/Classes/LocalVars.cs | 1 + .../Forms/LauncherForm/LauncherFormShared.cs | 13 ++++- 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/Novetus/NovetusCore/StorageAndFunctions/SecurityFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/SecurityFuncs.cs index d0692d2..d3f0f4f 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/SecurityFuncs.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/SecurityFuncs.cs @@ -267,12 +267,57 @@ public class SecurityFuncs return ipAddress; } - #if !BASICLAUNCHER +#if !BASICLAUNCHER public static async Task GetExternalIPAddressAsync() { var task = Task.Factory.StartNew(() => GetExternalIPAddress()); return await task; } - #endif +#endif + +#if LAUNCHER + //modified from https://stackoverflow.com/questions/14687658/random-name-generator-in-c-sharp + public static string GenerateName(int len) + { + CryptoRandom r = new CryptoRandom(); + string[] consonants = { "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "l", "n", "p", "q", "r", "s", "sh", "zh", "t", "v", "w", "x" }; + string[] vowels = { "a", "e", "i", "o", "u", "ae", "y" }; + string Name = ""; + Name += consonants[r.Next(consonants.Length)].ToUpper(); + Name += vowels[r.Next(vowels.Length)]; + int b = 2; //b tells how many times a new letter has been added. It's 2 right now because the first two letters are already in the name. + while (b < len) + { + Name += consonants[r.Next(consonants.Length)]; + b++; + Name += vowels[r.Next(vowels.Length)]; + b++; + } + + return Name; + } + + //https://www.c-sharpcorner.com/article/caesar-cipher-in-c-sharp/ + public static char cipher(char ch, int key) + { + if (!char.IsLetter(ch)) + { + return ch; + } + + char d = char.IsUpper(ch) ? 'A' : 'a'; + return (char)((((ch + key) - d) % 26) + d); + } + + public static string Encipher(string input, int key) + { + string output = string.Empty; + + foreach (char ch in input) + output += cipher(ch, key); + + return output; + } +#endif } #endregion \ No newline at end of file diff --git a/Novetus/NovetusLauncher/Classes/LocalVars.cs b/Novetus/NovetusLauncher/Classes/LocalVars.cs index 6a3f9bb..8f137b5 100644 --- a/Novetus/NovetusLauncher/Classes/LocalVars.cs +++ b/Novetus/NovetusLauncher/Classes/LocalVars.cs @@ -11,6 +11,7 @@ namespace NovetusLauncher #endregion #region Commands public static string important = ""; + public static string important2 = ""; #endregion } #endregion diff --git a/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs b/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs index ae96872..88b4b37 100644 --- a/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs +++ b/Novetus/NovetusLauncher/Forms/LauncherForm/LauncherFormShared.cs @@ -229,7 +229,7 @@ namespace NovetusLauncher GlobalFuncs.CreateAssetCacheDirectories(); ProductVersionLabel.Text = Application.ProductVersion; - LocalVars.important = SecurityFuncs.GenerateMD5(Assembly.GetExecutingAssembly().Location); + SetupImportantData(); NovetusVersionLabel.Text = GlobalVars.ProgramInformation.Version; SplashLabel.Text = SplashReader.GetSplash(); @@ -548,6 +548,15 @@ namespace NovetusLauncher } } + public void SetupImportantData() + { + CryptoRandom random = new CryptoRandom(); + string Name1 = SecurityFuncs.GenerateName(random.Next(4, 12)); + string Name2 = SecurityFuncs.GenerateName(random.Next(4, 12)); + LocalVars.important = Name1 + Name2; + LocalVars.important2 = SecurityFuncs.Encipher(LocalVars.important, random.Next(2, 9)); + } + public void ConsoleProcessCommands(string cmd) { switch (cmd) @@ -630,6 +639,8 @@ namespace NovetusLauncher GlobalFuncs.ConsolePrint("= dlldelete off | Turn off the deletion of opengl32.dll when ReShade is off.", 4, ConsoleBox); GlobalFuncs.ConsolePrint("= dlldelete on | Turn on the deletion of opengl32.dll when ReShade is off.", 4, ConsoleBox); GlobalFuncs.ConsolePrint("---------", 1, ConsoleBox); + GlobalFuncs.ConsolePrint(LocalVars.important2, 1, ConsoleBox); + GlobalFuncs.ConsolePrint("---------", 1, ConsoleBox); } public void SwitchStyles()