コード例 #1
0
        private static void Decrypt()
        {
            string pass = "******";
            string salt = "testeste";

            var result = SecureSerialization.DeserializeObjectFromFile("B:\\passwd.xml", Encoding.UTF8.GetBytes(pass), Encoding.UTF8.GetBytes(salt), 100, 1000);
        }
コード例 #2
0
        public static void SaveModel()
        {
            Assert.IsNotNull(CurrentModel);
            Assert.IsNotNull(authenticationResult);
            Assert.IsTrue(authenticationResult.Success);

            SecureSerialization.SerializeObjectToFile(ModelPath, CurrentModel, authenticationResult.EnteredPasswordAsBytes, authenticationResult.PasswordSalt, Settings.Default.AESIterations, Settings.Default.AESKeyIterations);
        }
コード例 #3
0
        private static void Crypt()
        {
            var test = new TestClass();

            test.TestProperty = "testtes";

            string pass = "******";
            string salt = "testeste";

            SecureSerialization.SerializeObjectToFile("B:\\passwd.xml", test, Encoding.UTF8.GetBytes(pass), Encoding.UTF8.GetBytes(salt), 100, 1000);
        }
コード例 #4
0
        public static void ChangeAuthData(AuthData oldData, AuthData newData)
        {
            Assert.IsTrue(oldData.Success);
            Assert.IsTrue(newData.Success);

            if (File.Exists(ModelPath))
            {
                var model = SecureSerialization.DeserializeObjectFromFile(ModelPath, oldData.EnteredPasswordAsBytes, oldData.PasswordSalt, Settings.Default.AESIterations, Settings.Default.AESKeyIterations);

                Assert.IsNotNull(model);

                SecureSerialization.SerializeObjectToFile(ModelPath, model, newData.EnteredPasswordAsBytes, newData.PasswordSalt, Settings.Default.AESIterations, Settings.Default.AESKeyIterations);
            }
        }
コード例 #5
0
        public static void LoadModel(AuthData authData)
        {
            Assert.IsTrue(authData.Success);

            authenticationResult = authData;

            if (File.Exists(ModelPath))
            {
                var model = SecureSerialization.DeserializeObjectFromFile(ModelPath, authenticationResult.EnteredPasswordAsBytes, authenticationResult.PasswordSalt, Settings.Default.AESIterations, Settings.Default.AESKeyIterations);

                CurrentModel = model as Model;

                //PasswordInfoLoader.Rehash(Settings.Default.KeyPath, authenticationResult.EnteredPasswordAsString);
            }

            if (CurrentModel == default(Model))
            {
                CurrentModel = new Model();

                SaveModel();
            }
        }