Im not sure what you think is so difficult with this, assuming you have already figured out how to do the encryption. Simplest way to do it is to have a Click event for the button to start the encryption and validate the key from inside that function, or call another function from inside it to validate the key then run your encryption algorithim