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.
Performing asymmetric encryption - iOS Tutorial
From the course: iOS Development: Security
Performing asymmetric encryption
- [Instructor] The KeychainFacade class can generate the private and the public key pair. These keys are required for asymmetric encryption. Next, we're going to implement the encryption feature. I start by declaring the encrypt method. Let's scroll down. The method has a single parameter of type string. This is our input to be encrypted. The method returns an optional data, and it might throw an error. We need the public key for asymmetric encryption. We can't proceed if there is no public key, so I need to make sure it exists. That's why I use the guard statement, guard let security key equals publicKey, else, we need to throw an error. We'll need a dedicated error for the case when there is no public key. I'm going to define a new error case called noPublicKey. Let's scroll up to the KeychainFacade error, and I'll add the new case, case noPublicKey. Now, let's complete the guard block. Throw KeychainFacadeError.noPublicKey. The next step is about choosing an asymmetric algorithm. I…
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)
-