I am trying to implement the new VerificationController.m class that Apple has released to fix an in-app purchase fraud problem.
Like everything released by Apple, this is another vague, incomplete and poorly explained document with a lot of voids and unknowns that cannot be circumvented / understood by everyone.
I am trying to implement this, but at the end of the code we see these four methods:
- (NSString *)encodeBase64:(const uint8_t *)input length:(NSInteger)length { #warning Replace this method. return nil; } - (NSString *)decodeBase64:(NSString *)input length:(NSInteger *)length { #warning Replace this method. return nil; } #warning Implement this function. char* base64_encode(const void* buf, size_t size) { return NULL; } #warning Implement this function. void * base64_decode(const char* s, size_t * data_len) { return NULL; }
You can see that Apple was lazy to implement the C functions at the end of the code. Since my C / C ++ features stink, I see that I need to implement these two functions in C / C ++ and that they should return char and void (???). Other people have placed routines to do this on SO, but they are either in Objective-C or they don't return characters and void (??).
NOTE. This is another problem: how does the method return void if it is used by Apple in this form?
uint8_t *purchase_info_bytes = base64_decode([purchase_info_string cStringUsingEncoding:NSASCIIStringEncoding], &purchase_info_length);
should uint8_t be returned?
NOTE 2. Another problem is that the apple says base64_encode is required, but it is not used in the code provided by them. I think they smoke bad things, or my knowledge of C / C ++ really stinks.
So, back to my first question. Can someone send / specify a method that can perform a task that follows the requirements of the declared base64_encode and base64_decode methods? Please refrain from publishing Objective-C methods that are incompatible with these requirements set by Apple.
Thanks.