Example #1
0
        public void WrongPasswordTest()
        {
            var sr = new StringEncryptor
            {
                Password = "******"
            };

            var encrypted = sr.EncryptString(input);

            Assert.AreNotEqual(input, encrypted);

            sr.Password = "******";
            sr.DecryptString(encrypted); // throws a cryptographic exception.
        }
Example #2
0
        public void RoundTripTest()
        {
            var sr = new StringEncryptor
            {
                Password = "******"
            };

            var encrypted = sr.EncryptString(input);

            Assert.AreNotEqual(input, encrypted);

            var decrypted = sr.DecryptString(encrypted);

            Assert.AreEqual(input, decrypted);
        }
Example #3
0
        public static AppSettings Get()
        {
            var settingsPath = Assembly.GetExecutingAssembly().Location;

            Log.Debug($"Loading settings from {settingsPath}");
            var configuration = ConfigurationManager.
                                OpenExeConfiguration(settingsPath);

            var appSettings  = configuration.AppSettings.Settings;
            var clientSecret = StringEncryptor.DecryptString(appSettings[nameof(AppSettings.ClientSecret)]?.Value);

            return(new AppSettings(appSettings[nameof(AppSettings.IdentityUrl)]?.Value,
                                   appSettings[nameof(AppSettings.ApiUrl)]?.Value,
                                   clientSecret));
        }
Example #4
0
        public void WrongSeedTest()
        {
            var sr = new StringEncryptor
            {
                Password = "******"
            };

            var encrypted = sr.EncryptString(input);

            Assert.AreNotEqual(input, encrypted);

            sr.Seed = Guid.NewGuid();

            var decrypted = sr.DecryptString(encrypted);

            Assert.AreNotEqual(input, decrypted);
        }