Exemplo n.º 1
0
        public PasswordManager(string p_username, string p_password)
        {
            username = p_username;

            salt = new Salt();
            salt.generateSaltBytes();

            hash = new Hash();
            hash.computeHashBytes(Encoding.UTF8.GetBytes(p_password), salt.saltBytes);
        }
Exemplo n.º 2
0
        public bool IsPasswordMatch(User userToCompare)
        {
            // Get password byte array
            byte[] passwordBytes = Encoding.UTF8.GetBytes(Hash);

            // Get salt byte array
            Salt salt = new Salt();
            salt.saltString = userToCompare.Salt;
            byte[] saltBytes = salt.getSaltBytes();

            // Compute hash byte array from password and salt
            Hash hash = new Hash();
            hash.computeHashBytes(passwordBytes, saltBytes);
            string hashString = hash.getHashString();

            // Compare the two
            if (userToCompare.Hash == hashString)
            {
                return true;
            }
            return false;
        }