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.

Creating the private key

Creating the private key - iOS Tutorial

From the course: iOS Development: Security

Start my 1-month free trial

Creating the private key

- [Instructor] Now let's see how asymmetric cryptography works in iOS. I am going to create a new project using the Single View App template. Let's call it AsymmetricCryptoDemo. We're going to implement the class that exposes cryptography-related features. First, I create a new file called KeychainFacade. So let's add a new file, Swift file, and it's called KeychainFacade. We'll rely on the security framework, so let's import it. Next, I declare the KeychainFacade class. First, we'll generate the private key. I'll use the keychain to store the generated key securely. We start the key creation by defining a unique tag of type data, so I create a private static constant, let's call it tagData equals. We'll create a string constant and convert it to data. It should be unique, so let's call it com.asymmetricCryptoDemo.keys.mykey. And I convert it to data using the Strings data method, using a UTF-8 encoding, next, I define the dictionary with the attributes of the key. The keys should be…

Contents