Esempio n. 1
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            string plainText  = textBox1.Text.ToString(); // original plaintext
            string cipherText = "";                       // encrypted text
            string passPhrase = "Pas5pr@se";              // can be any string
            string initVector = "@1B2c3D4e5F6g7H8";       // must be 16 bytes

            // Before encrypting data, we will append plain text to a random
            // salt value, which will be between 4 and 8 bytes long (implicitly
            // used defaults).
            EnhancedCipher rKey = new EnhancedCipher(passPhrase, initVector);

            // Encrypt the same plain text data 10 time (using the same key,
            // initialization vector, etc) and see the resulting cipher text;
            // encrypted values will be different.
            for (int i = 0; i < 10; i++)
            {
                cipherText    = rKey.Encrypt(plainText);
                textBox2.Text = cipherText;

                plainText = rKey.Decrypt(cipherText);
            }

            // Make sure we got decryption working correctly.
        }
Esempio n. 2
0
        private string DecryptLevel(string cipherText)
        {
            string plainText  = " ";                // original plaintext
            string passPhrase = "Pas5pr@se";        // can be any string
            string initVector = "@1B2c3D4e5F6g7H8"; // must be 16 bytes

            // Before encrypting data, we will append plain text to a random
            // salt value, which will be between 4 and 8 bytes long (implicitly
            // used defaults).
            EnhancedCipher rKey = new EnhancedCipher(passPhrase, initVector);

            // Encrypt the same plain text data 10 time (using the same key,
            // initialization vector, etc) and see the resulting cipher text;
            // encrypted values will be different.
            for (int i = 0; i < 10; i++)
            {
                plainText = rKey.Decrypt(cipherText);
            }

            return(plainText);
        }
Esempio n. 3
0
        private string DecryptLevel(string  cipherText)
        {
            string  plainText  = " ";// original plaintext
            string  passPhrase = "Pas5pr@se";        // can be any string
            string  initVector = "@1B2c3D4e5F6g7H8"; // must be 16 bytes

            // Before encrypting data, we will append plain text to a random
            // salt value, which will be between 4 and 8 bytes long (implicitly
            // used defaults).
            EnhancedCipher rKey =	new EnhancedCipher(passPhrase, initVector);

            // Encrypt the same plain text data 10 time (using the same key,
            // initialization vector, etc) and see the resulting cipher text;
            // encrypted values will be different.
            for (int i=0; i<10; i++)
            {
                plainText =rKey.Decrypt(cipherText);

            }

            return plainText;
        }
Esempio n. 4
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            string  plainText  = textBox1.Text.ToString();// original plaintext
            string  cipherText = "";                 // encrypted text
            string  passPhrase = "Pas5pr@se";        // can be any string
            string  initVector = "@1B2c3D4e5F6g7H8"; // must be 16 bytes

            // Before encrypting data, we will append plain text to a random
            // salt value, which will be between 4 and 8 bytes long (implicitly
            // used defaults).
            EnhancedCipher rKey =	new EnhancedCipher(passPhrase, initVector);

            // Encrypt the same plain text data 10 time (using the same key,
            // initialization vector, etc) and see the resulting cipher text;
            // encrypted values will be different.
            for (int i=0; i<10; i++)
            {

            cipherText =rKey.Encrypt(plainText);
            textBox2.Text=cipherText;

            plainText =rKey.Decrypt(cipherText);

            }

            // Make sure we got decryption working correctly.
        }