From the course: iOS Development: Security

Unlock the full course today

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

Performing asymmetric encryption continued

Performing asymmetric encryption continued - iOS Tutorial

From the course: iOS Development: Security

Start my 1-month free trial

Performing asymmetric encryption continued

- [Instructor] Finally, we can call the sec key create encrypted data function. I use guard and store the return data in the constant called completed text data, guard let encrypted text data equals sec key create encrypted data. Now the first parameter is the public key. The second is the algorithm, and the third is the data to be encrypted, textData, but we have to cast the data to core foundation data. The final parameter is the reference to an error. Though I have to define an optional error variable, of type unmanaged CF error. Var error of type unmanaged CF error. And I pass its address to the function. The function should return data. If the call fails, we throw an error. I check if the error reference contains a valid error. If let encryption error equals error. Otherwise, I should tell the caller that the error is unknown. So, I create two new error cases. Forwarded, which has an associated value of type error, Forwarded, which has an associated value of type error, and…

Contents