Thursday, 24 February 2011

objective-c how to remove encryption from this code


hi

new objective-c , finding difficult grasp how works.

anyways, code below retrieves encrypted xml plist file server , decrypts use in iphone app. discovered encryption whole big issue don't want deal right now, need remove encryption part (i have no problem doing on server side).

it's this:
server side: xml plist file > encrypt > base64encode
iphone side: request , receive file > base64decode > decrypt > xml plist file.

need remove decrypt part, it's this:
server side: xml plist file > base64encode
iphone side: request , receive file > base64decode > xml plist file.

have played code can't right. appreciated. sure it's seckeywrapper, not able remove it.

thanks

code:
-(void)sync{      nsurl *url = [nsurl urlwithstring:@"http://www.mydomain.com/plist-settings.php"]; //retrieve file      nsurlrequest *request = [nsurlrequest requestwithurl:url cachepolicy:nsurlrequestreloadignoringlocalcachedata timeoutinterval:5.0];          [nsurlconnection connectionwithrequest:request delegate:self];      sync_data = [[nsmutabledata alloc] init];  }    - (void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)_data{      [sync_data appenddata:_data];  }    - (void)connectiondidfinishloading:(nsurlconnection *)connection{      char * key = "(masfi14%12as./*";      nsdata * symmetrickey = [nsdata datawithbytes:key length:16];      ccoptions pad = kccoptionecbmode;            nsmutabledata *thedata = [[nsdata datafrombase64string:[[nsstring alloc] initwithdata:sync_data encoding:nsutf8stringencoding]] mutablecopy];      if ([thedata length] == 0) {          [thedata release];          return;      }      sync_data = [[[seckeywrapper sharedwrapper] docipher:thedata key:symmetrickey context:kccdecrypt padding:&pad] mutablecopy];        [thedata release];            nsdictionary *dictserver = nil;      cfpropertylistref plist = cfpropertylistcreatefromxmldata(kcfallocatordefault,(cfdataref)sync_data, kcfpropertylistimmutable, null);  
 

i suggest mapping each of steps code, in order make things clearer:

code:
      sync_data  -->  base64decode --> thedata      thedata    -->  decrypt      -->  sync_data      sync_data  -->  xml plist    -->  plist  
now have remove relevant step... luck :)
 


Forums iPhone, iPad, and iPod Touch iOS Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment