From the course: iOS Development: Security

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Asymmetric encryption and decryption demo

Asymmetric encryption and decryption demo - iOS Tutorial

From the course: iOS Development: Security

Start my 1-month free trial

Asymmetric encryption and decryption demo

- [Instructor] Now let's test our encryption class. I switched to the ViewController and I start by defining a private method. I call it encryptDecrypt, so private func encryptDecrypt. It has no input arguments and it doesn't return anything either. We'll need a KeychainFacade instance first. So I create a constant let facade equals KeychainFacade. Then I define a constant and assign it the value Super secret text. Let me scroll up a bit. This is the text that we're going to encrypt. So next we'll call the facade method. These methods can throw so we'll call them from within a do catch block. Let's encrypt the text. I'll use optional binding to extract the result of calling facade encrypt into a constant. If let encryptedData equals and I use try to call facade.encrypt and that's passed in our text. If the encryption was successful, I print a console log, print Text encryption successful. Next, we'll decrypt the encrypted data. Again, we use optional binding and the result of calling…

Contents