ios - How to split bytes from NSData? -
so.. have encrypted data server need decrypted can full response json. thing need split first 16 bytes of data iv decryption , rest of bytes encrypted data. tried below method:
nsdata *wholedata = [[nsdata alloc] initwithbase64encodedstring:@"iysayh92saft5t/ueqqtltaft1ow33fxpldusrmatblury/6z1vgk1kfmyerwhpbi85t7znzdqal5v8cu60dcjlwvqdi6kdwbmcq0+l62im7ixw60+g8gtkm+6+mltye" options:0]; nsdata *d1 = [wholedata subdatawithrange:nsmakerange(0, 16)]; nsdata *d2 = [wholedata subdatawithrange:nsmakerange(17, wholedata.length)]; nsdata *enc = d2; nsdata *key = [[nsdata alloc] initwithbase64encodedstring:@"alskd81039aisdf/tusd8341iasldkjfy=" options:0]; nsdata *enciv = d1; nsdata *decrypted = [fbencryptoraes decryptdata:enc key:key iv:enciv];
then got below error:
terminating app due uncaught exception 'nsrangeexception', reason: '*** -[nsconcretedata subdatawithrange:]: range {17, 96} exceeds data length 96'
how can fix issue?
nsdata *d2 = [wholedata subdatawithrange:nsmakerange(17, wholedata.length - 17)];
Comments
Post a Comment