I'm trying to create and send an encrypted image via an iMessage app. I've never done something like this before and I'm not even really sure where to start.
I know that there are GitHub repos like this one that provide a lot of different encryption methods. I also know that Apple provides compression libraries on iOS. What I don't know is what algorithms and compression options to use.
I need it to be as small as possible, but still maintain a reasonably high image quality (think Instagram quality or higher).
Short version: What is the best way to compress and encrypt a UIImage on iOS?
Use ZIP for compression and AES for encryption. ZIP first and then encrypt, AES is available in the Common Crypto. There are many answers on SO about encryption with Common Crypto in iOS.
But how will the image get decrypted by the receiver and how will the encryption key be shared between the sender and receiver?
AES encryption increases the size by at most 16 bytes of padding.
On an iPhone 5S I get encryption speed of 440MB/s. Common Crypto uses the built-in encryption hardware, software implementations such as CryptoSwift are much (orders of magnitude) slower.