0

How do you encrypt and decrypt a string on iOS (AES256 or AES128)? I have looked through so many solution but couldn't find anything that works properly.

Example:

NSString *plainString = @"This string will be encrypted";
NSString *key = @"myKey";

Now, how do I encrypt plainString using key? And how do I do the opposite?

It can be either AES256 or AES128 algorithms, doesn't matter.

I would really appreciate your help!

Leonardo DaVintik
  • 555
  • 1
  • 9
  • 18
  • Be very careful of the iOS Algorithms you find on the web for this.. many were written poorly and will fail to decode in other languages and generally not play nice due to padding and character encoding issues. – Kenrik March May 08 '13 at 23:23
  • How are you expecting AES128 or 256 to work with an 80-bit key? – 一二三 May 09 '13 at 01:05
  • Can you elaborate? I come from openssl background, where encrypting and decrypting is as simple as using aes-256-cbc command. How does iOS go about encryption? – Leonardo DaVintik May 09 '13 at 04:43
  • @KenrikMarch- Where I can get correct implementation of AES-128? It will be lot better if you can help? – iEinstein Feb 26 '18 at 14:18

0 Answers0