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 - iOS Tutorial
From the course: iOS Development: Security
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Asymmetric cryptography overview1m 25s
-
(Locked)
Creating the private key5m 49s
-
(Locked)
Retrieving the private key from the Keychain4m 32s
-
(Locked)
Defining the asymmetric key accessors2m 9s
-
(Locked)
Performing asymmetric encryption4m 10s
-
(Locked)
Performing asymmetric encryption continued2m 26s
-
(Locked)
Performing asymmetric decryption3m 41s
-
(Locked)
Asymmetric encryption and decryption demo3m 9s
-
(Locked)
-