I am testing the RNCryptor lib for a project. Basically we will be encrypting the data on iOS client and then decrypting on the .NET server. For my test to ensure its working, I am trying to encrypt a string in iOS and C# but get different results. The code snippet is below for both:
C#
string s = "this is a test";
RNCryptor.Encryptor en = new Encryptor();
en.TextEncoding = System.Text.Encoding.UTF8; // I tried all kinds of encoding but no luck
string enc = en.Encrypt(s, "0x100001");
Result: AgEIqMSdKGo8US1nTSVoHOcqf94mzuYbB7NOyB1Mppa0fELEw868kX6YVpIywZVdxTAUafVu7FfTlrzUDVXc4XSn3QWc3vSxAXSxDQtNAZuW2g==
iOS
NSData *data = [@"this is a test" dataUsingEncoding:NSUTF8StringEncoding];
NSError *error;
NSData *encryptedData = [RNEncryptor encryptData:data
withSettings:kRNCryptorAES256Settings
password:@"0x100001"
error:&error];
Result:
AwETKDI+AhqRFxUn0zKnoQL9oDx+Nf4/NwtTcnZcN/OpopBgwQ8Qy5nXwM9VDdOMRlmqJUCgYMs6hGzga0K7/yMGXlipfk1nYPhn4hJs2uKyzA==
Can you guys please let me know where the problem is? I expect it to produce the same encrypted string but its not. I would appreciate a quick response as we need to decide on the library.