Beispiel #1
0
    // This routine handles the Form's Load event, setting up the sample.

    private void frmMain_Load(object sender, System.EventArgs e)
    {
        // Set the default crypto type.

        crpSample = new SampleCrypto("Rijndael");

        // Set the path to save the key file to the Solution root folder by stripping

        // "bin" from the current directory.

        string strCurrentDirectory = Environment.CurrentDirectory.Substring(
            Environment.CurrentDirectory.Length - 2);

        // Initialize paths for both types of key files.

        strRijndaelSaltIVFile  = strCurrentDirectory + "RijndaelSaltIV.dat";
        strTripleDESSaltIVFile = strCurrentDirectory + "TripleDESSaltIV.dat";

        // Set the current key file path to the key for default crypto type.

        strCurrentKeyFile = strRijndaelSaltIVFile;

        // Call Select() to put focus on the "Encrypt" button and prevent the text in
        // the TextBox from being automatically highlighted.

        btnEncrypt.Select();
        FormHasLoaded = true;
    }
Beispiel #2
0
    // This routine handles the CheckedChanged event for the RadioButton controls.

    private void RadioButtons_CheckedChanged(object sender, System.EventArgs e)
    {
        if (FormHasLoaded)
        {
            if (optRijndaelAdv.Checked)
            {
                crpSample         = new SampleCrypto("Rijndael");
                strCurrentKeyFile = strRijndaelSaltIVFile;
            }
            else
            {
                crpSample         = new SampleCrypto("TripleDES");
                strCurrentKeyFile = strTripleDESSaltIVFile;
            }
        }
    }