1

I am working on the static application that means no webservices. My application contains activation page so that we need to enter text inside that textfield to validate.

if([textfield.text isEqualToString:@"AKS_BI"]) {
     //loading home screen
 } else {
//show alert
 }

For this one, I would like to encrypt the "AKS_BI" in order to hide the string while reverse engineering or Mat testing.

Can you anyone help me on this.

Jagat Dave
  • 1,643
  • 3
  • 23
  • 30
  • 5
    first decide which encryption method you want ?. refer this link for AES encryption. http://stackoverflow.com/questions/1400246/aes-encryption-for-an-nsstring-on-the-iphone – Rince Thomas Feb 10 '16 at 08:32
  • This just moves the problem from keeping "AKS_BI" secret to keeping the encryption key secret. Who are you protecting the key from, the user or someone else? – zaph Feb 10 '16 at 18:29

3 Answers3

1

To encrypt:

//for best practise encrypting string length must be >=8
NSString *yourString=@"abcdefghij";

NSString *YourPasswordString = @"123456";//i've took static but you can set it dynamically
NSString *encryptPassword;

//Encrypt    
NSData *data = [YourPasswordString dataUsingEncoding: NSASCIIStringEncoding];
NSData *encryptedData = [data AESEncryptWithPassphrase:yourString];

//Encode Base 64    
[Base64 initialize];
encryptPassword = [Base64 encode:encryptedData];

For more details you can check here

Hope this helps.

Satish A
  • 584
  • 4
  • 17
0

You can use this library https://github.com/RNCryptor/RNCryptor.

However, you will still need to store the encryption key securely. For that I would recommend to split them up and perform some operation on them to combine.

  • This has just moved the problem, might as well use the advice for the encryption key for "AKS_BI". – zaph Feb 10 '16 at 18:27
-1
  1. Download AES encryption files from github. Download from here
  2. After adding these downloaded files in your project now compare ,

           if ([[AESCrypt encrypt:textfield.text password:[[NSBundle mainBundle] bundleIdentifier]] isEqualToString:ACTIVATION_STRING]) 
    
  3. Here, ACTIVATION_STRING = hYjhuOO+GYTUBS05== .... This encrypted string needs to be created with the below syntax and make sure that remove the below syntax from code after generation of encrypted string,

       NSString *encryptedData = [AESCrypt encrypt:@"AKS_BI" password: [[NSBundle mainBundle] bundleIdentifier]];
    

That's it. It simple.

Bharath
  • 190
  • 7