예제 #1
0
        private int AddNewPlayerDefinition(int newID, string playerName, string playerPassword, string playerLogin)
        {
            PasswordEncryptor encryptor = new PasswordEncryptor();

            realm.Write(() =>
            {
                realm.Add(new PlayerDefinition()
                {
                    ID             = newID,
                    PlayerName     = playerName,
                    PlayerPassword = encryptor.EnctyptPassword(playerPassword),
                    PlayerLogin    = playerLogin,
                });
            });

            return(newID);
        }
예제 #2
0
        private bool CheckPasswordCorrectness(string password, string hashedPassword)
        {
            PasswordEncryptor decryptor         = new PasswordEncryptor();
            string            decryptedPassword = "";

            try
            {
                decryptedPassword = decryptor.DecryptPassword(hashedPassword, password);
            }
            catch (Exception ex)
            {
                var logger = NLog.LogManager.GetCurrentClassLogger();
                logger.Error($"Error while trying decrypt password: {ex.Message}.");
            }
            if (decryptedPassword == password)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }