In c #
void test(){ string ctB64 = encrypt("hola"); Console.WriteLine(ctB64);
. In objective-c add the CocoaSecurity library from https://github.com/kelp404/CocoaSecurity
#import "CocoaSecurity.h" #import "Base64.h" β¦ - (void) test{ unsigned char bytes[] = { 0x10, 0x16, 0x1F, 0xAD, 0x10, 0x10, 0xAA, 0x22, 0x12, 0x51, 0xF1, 0x1E, 0x15, 0x11, 0x1B, 0x10 }; // must be the same as in c# NSData *iv = [NSData dataWithBytesNoCopy:bytes length:16 freeWhenDone:YES]; NSData* key = [@"0123456789123456" dataUsingEncoding:NSUTF8StringEncoding]; CocoaSecurityResult *result = [CocoaSecurity aesEncrypt:@"hola" key:key iv:iv]; NSLog(@"%@", result.base64); // the same as in c# NSData *data = [NSData dataWithBase64EncodedString:result.base64]; CocoaSecurityResult *result2 = [CocoaSecurity aesDecryptWithData:data key:key iv:iv]; NSLog(@"%@", result2.utf8String); // show "hola" }
user2606584 Dec 11 '15 at 1:11 2015-12-11 01:11
source share