Пример #1
0
        public User loginUser(string username, string password)
        {
            User user = getUser(username);

            if (user == null)
            {
                return null;
            }

            CryptoService.Service proxy = new CryptoService.Service();

            try
            {

                string decrypted = proxy.Decrypt(user.getPassword());

                if (password == decrypted)
                {
                    return user;
                }
                else
                {
                    Debug.WriteLine("Password was incorrect");
                    return null;
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                return null;
            }
        }
Пример #2
0
        public User getUser(string username)
        {
            CryptoService.Service proxy = new CryptoService.Service();

            try
            {
                string[] users = File.ReadAllLines(path);

                for (int i = 0; i < users.Length; i++)
                {
                    string[] fields = users[i].Split(' ');
                    if (fields.Length == 3 && fields[1] == username)
                    {
                        string decrPass = proxy.Decrypt(fields[2]);
                        User user = new User(Convert.ToInt32(fields[0]), fields[1], decrPass);
                        return user;
                    }

                }

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }

            return null;
        }