예제 #1
0
        public LoginForm(string passwordFilePath)
        {
            InitializeComponent();

            this.passwordFilePath = passwordFilePath;

            this.pwInfo = PasswordInformation.Load(this.passwordFilePath);
            this.authenticationResult = new AuthData();
        }
        public static void Rehash(string passwordFilePath, string password)
        {
            Assert.IsTrue(File.Exists(passwordFilePath));
            Assert.IsTrue(password.Length > 0);

            var pwInfo = PasswordInformation.Load(passwordFilePath);

            pwInfo.RenewHash(password);
            pwInfo.Save(passwordFilePath);
        }
예제 #3
0
        public void TestHashRenew()
        {
            using (var tmp = TempDir.Create())
            {
                var file = Path.Combine(tmp.Name, "key.xml");

                var created = PasswordInformation.Create(file, pass, hashIterations);

                created.RenewHash(pass);
                created.Save(file);

                var loaded = PasswordInformation.Load(file);
                Assert.IsTrue(loaded.PasswordIsCorrect(pass));
                Assert.IsTrue(loaded.PasswordSalt.SequenceEqual(created.PasswordSalt));
            }
        }
        public static AuthData Authenticate(string passwordFilePath, string password)
        {
            var pwInfo = PasswordInformation.Load(passwordFilePath);
            var result = new AuthData();

            result.Success      = false;
            result.PasswordSalt = pwInfo.PasswordSalt;

            if (pwInfo.PasswordIsCorrect(password))
            {
                result.EnteredPasswordAsString = password;
                result.PasswordSalt            = pwInfo.PasswordSalt;
                result.Success = true;
            }

            return(result);
        }