How to assign the task to the labels with in the timer event
<p>I have one problem, In my GUI I made two lables named ECU_1, ECU_2. I want to send the data  from one label for example ECU_1 to another label like ECU_2 with the help of timer like at every 5sec's and the data is not so important whatever it is but the security of the data is important that's why I used Rijndael Algorithm for providing security of the data. I made two functions one for encrypting the data and for decrypting the data.</p>

<pre><code> public string Encrypt(string plainText, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations,string initVector,
                             int keySize)
    {
        byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector);
        byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue);
        byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
        PasswordDeriveBytes password = new PasswordDeriveBytes(passPhrase, saltValueBytes, hashAlgorithm, passwordIterations);
        byte[] keyBytes = password.GetBytes(keySize / 8);
        RijndaelManaged symmetricKey = new RijndaelManaged();
        symmetricKey.Mode = CipherMode.CBC;
        ICryptoTransform encryptor = symmetricKey.CreateEncryptor(keyBytes, initVectorBytes);
        MemoryStream memoryStream = new MemoryStream();
        CryptoStream cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write);
        cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);
        cryptoStream.FlushFinalBlock();
        byte[] cipherTextBytes = memoryStream.ToArray();
        memoryStream.Close();
        cryptoStream.Close();
        string cipherText = Convert.ToBase64String(cipherTextBytes);
        return cipherText;
    }

    public string Decrypt(string cipherText,string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations,string initVector,
                             int keySize)
    {
        byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector);
        byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue);
        byte[] cipherTextBytes = Convert.FromBase64String(cipherText);
        PasswordDeriveBytes password = new PasswordDeriveBytes(passPhrase, saltValueBytes, hashAlgorithm, passwordIterations);
        byte[] keyBytes = password.GetBytes(keySize / 8);
        RijndaelManaged symmetricKey = new RijndaelManaged();
        symmetricKey.Mode = CipherMode.CBC;
        ICryptoTransform decryptor = symmetricKey.CreateDecryptor(keyBytes, initVectorBytes);
        MemoryStream memoryStream = new MemoryStream(cipherTextBytes);
        CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read);
        byte[] plainTextBytes = new byte[cipherTextBytes.Length];
        int decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length);
        memoryStream.Close();
        cryptoStream.Close();
        string plainText = Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount);
        return plainText;
    }

// this is my label4 named ECU_1 calling Encrypt function and passing the parameters to it and displaying the cipher text to the textBox1

private void label4_Click(object sender, EventArgs e)
    {
       string amd = crypo.Encrypt("Hello, World!", "Pas5pr@se", "s@1tValue", "SHA1", 2, "@1B2c3D4e5F6g7H8", 256);
        textBox1.Text = amd;
    }

   //this is my label5 named ECU_2 reading the cipher text from textbox1 and calling Decrypt function and passing the parameters to it and displaying the plain text in textBox2 
    private void label5_Click(object sender, EventArgs e)
    {
        textBox2.Text = crypo.Decrypt(amd, "Pas5pr@se", "s@1tValue", "SHA1", 2, "@1B2c3D4e5F6g7H8", 256);

    }
</code></pre>

<p>Now my problem is that when I am clicking the ECU_1 label then it calling the encrypt function and converting plain text into cipher text and same as with ECU_2 when I am clicking on ECU_2 then it do its operation but I want this should happen in timer event, when my timer starts the ECU_1 encrypt the data and send it and ECU_2 decrypt the data at every 5000ms not by clicking on ECU_1 and ECU_2 and if it does in timer then it is not guranted that ECU_1 is the one who is sending the data and ECU_2 is the one who is receieving the data.  like for example  </p>

<pre><code> private void timer1_Tick(object sender, EventArgs e)
    {
        amd = crypo.Encrypt("Hello, World!", "Pas5pr@se", "s@1tValue", "SHA1", 2, "@1B2c3D4e5F6g7H8", 256);
        textBox1.Text = amd;
        textBox2.Text = crypo.Decrypt(amd, "Pas5pr@se", "s@1tValue", "SHA1", 2, "@1B2c3D4e5F6g7H8", 256);

    }
</code></pre>

<p>I am not getting how I should write the code to get the guaranty the ECU_1 is sending the data to ECU_2 and I am enabling the timer by my button event.</p>

<p>If the problem is not clear then write me I will try to explain in more simpler way.</p>

<p>Please help me out </p>

<p>Thanks in advance</p>
