public void Encrypt_And_Decrypt() { string test = "Fancy String"; string testEncrypted = CryptoObfuscation.Encrypt(test); Assert.AreNotEqual(test, testEncrypted); Assert.AreEqual(test, CryptoObfuscation.Decrypt(testEncrypted)); }
/// <summary> /// Will setup your project with logging & an exception processor /// </summary> /// <param name="projectName">The name of the project, used for context in logging and potentially elsewhere</param> /// <param name="setupLogging">Should logging be setup, will default to a project name specific appdata location</param> /// <param name="onExceptionRecieved">Something to handle unhandled exceptions</param> public static void RunOnetimeSetup(string projectName, bool setupLogging = true, ExceptionProcessor onExceptionRecieved = null, int ageMaxInDaysToKeepLogs = 10) { if (g_isSetup) { return; } ProjectName = projectName; AppDataRoot = AppDataHelper.EstablishAppDataLocation(ProjectName); CryptoObfuscation.Seed(projectName); TypeXT.RegisterSpecialDouble <GridLength>(gl => gl.Value); if (setupLogging) { Logger.SetupLogFile(AppDataHelper.EstablishAppDataLocation(ProjectName, "Logs")); PurgeAllLogsOlderThan(TimeSpan.FromDays(ageMaxInDaysToKeepLogs)); } if (onExceptionRecieved != null) { #if WINDOWS_UWP Application.Current.UnhandledException += Current_UnhandledException; #else Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; #endif } g_isSetup = true; #if WINDOWS_UWP void Current_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e) #else void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) #endif { if (g_blockReentrancy) { return; } g_blockReentrancy = true; try { if (onExceptionRecieved(e.Exception)) { e.Handled = true; } else { throw e.Exception; } } catch { } finally { g_blockReentrancy = false; } } }
public void Setup() { CryptoObfuscation.Seed("Unit Testing"); }