Esempio n. 1
0
        public void SetPassword(string password, IEncrypter encrypter)
        {
            if (string.IsNullOrWhiteSpace(password))
            {
                //TODO: Validate password power?
                throw new SmartFridgeException("empty_password", "Password cant be empty.");
            }

            Salt     = encrypter.CreateSalt(8);
            Password = encrypter.GenerateSaltedHash(Encoding.UTF8.GetBytes(password), Encoding.UTF8.GetBytes(Salt));
        }
Esempio n. 2
0
        public bool ValidatePassword(string password, string salt, IEncrypter encrypter)
        {
            var hashedPassword = encrypter.GenerateSaltedHash(Encoding.UTF8.GetBytes(password), Encoding.UTF8.GetBytes(salt));

            return(Password.Equals(hashedPassword));
        }