Click here to Skip to main content
15,891,687 members
Articles / Programming Languages / C#

How to make keyloggers life difficult

Rate me:
Please Sign up or sign in to vote.
4.84/5 (21 votes)
20 Jan 2013CPOL4 min read 42.2K   919   60  
This secure textbox deceptive keyloggers
using System;
using System.Windows.Forms;

namespace AntiKeylogger
{
    public partial class DemonstrationForm : Form
    {
        public DemonstrationForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show((maskedTextBox1.Text == "MyPassword1").ToString());
        }

        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show((secureTextBox1.Password == "MyPassword1").ToString());
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox3.Text != "")
                secureTextBox1.ID = textBox3.Text;
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
                maskedTextBox1.PasswordChar = '*';
            else
                maskedTextBox1.PasswordChar = '\0';
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox2.Checked)
                secureTextBox1.PasswordChar = '*';
            else
                secureTextBox1.PasswordChar = '\0';
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Student
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions