//Event listener on clic of encrypt button private void encryptButton_Click(object sender, EventArgs e) { //Creating an instance of encryption/decryption service EncryptionServiceReference.ServiceClient encryptionService = new EncryptionServiceReference.ServiceClient(); //Calling the encrypt method of the service on click of encrypt button string encrypted = encryptionService.Encrypt(encryptText.Text); //Assigning the encrypted string to the label encryptedText.Text = encrypted.ToString(); //Assigning the encrypted string to the decrypt textbox DecryptText.Text = encrypted.ToString(); }
//Event listener on click of decrypt button private void decryptButton_Click(object sender, EventArgs e) { try { //Creating an instance of encryption/decryption service EncryptionServiceReference.ServiceClient encryptionService = new EncryptionServiceReference.ServiceClient(); //Calling the decrypt method of the service on click of decrypt button string decrypted = encryptionService.Decrypt(DecryptText.Text); //Assigning the decrypted string to the label DecryptedString.Text = decrypted.ToString(); } //Catching the exception when an invalid String is entered catch (Exception excep) { DecryptedString.Text = "Please enter a valid string"; } }