1

I am using the AES encryption using the below code,

NSString *encryptedString =  [AESCrypt encrypt:@"str" password:@"password"];

The same string is not decoded correctly in .net server. The code is being used in .net server is as below,

AesEncryption = new RijndaelManaged();
AesEncryption.KeySize = 256;
AesEncryption.BlockSize = 128;
AesEncryption.Mode = CipherMode.CBC;
AesEncryption.Padding = PaddingMode.PKCS7;
string keyStr = "cGFWDwzc3dvcmQAAAAAAwzc3==";
string ivStr = "aEdcGFzc3dvcmQwzc3AvcmQAAAAA==";
byte[] ivArr = Convert.FromBase64String(keyStr);
byte[] keyArr = Convert.FromBase64String(ivStr);
AesEncryption.IV = ivArr;
AesEncryption.Key = keyArr;

Can you please help me on this.

1
  • 1
    I would suggest to use base64 encoding. Commented Jul 14, 2016 at 11:06

4 Answers 4

0

Use the below link: Add iOS files and implement the same provided in the header files and ask your .Net developer to work on the same.

https://github.com/Pakhee/Cross-platform-AES-encryption

Sign up to request clarification or add additional context in comments.

1 Comment

That library is terrible. RNCryptor is a much better alternative.
0

Have you try below code for EncodeToPercentEscapeString to encrypt you string.

-(NSString *) encodeToPercentEscapeString
{
    return (__bridge_transfer NSString *) CFURLCreateStringByReplacingPercentEscapes(NULL,
                                                                            (CFStringRef) self,
                                                                            ((CFStringRef) @" !*'();:@&=+$,/?%#[]"));
}

NSString *password = @"password_123";
NSString *encryptString = [password encodeToPercentEscapeString];

Comments

0

We do have AES , SHA , MDM5 etc encryption techniques available in iOS to encrypt the data/strings for ensuring the security of data transmit over the air,

Specifically i prefer to use AES 256 encryption you can follow the tutorial for encryption of your string given in the URL : http://robnapier.net/aes-commoncrypto

Once you encrypted your string , you can send that to .net/ back end using web service.

To send the data to .net using web service the answer with 3 reputations in the question here : Send parameters to a web service will help you.

1 Comment

Hi, Can i get the download link for that RNCryptor.
0

For a starter, you mixes up iv and key:

                                        VVVVVV
byte[] ivArr = Convert.FromBase64String(keyStr);
byte[] keyArr = Convert.FromBase64String(ivStr);
                                         ^^^^^^

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.