iPhone - finalizing Apple's vague "VerificationController.m"
===

I am trying to implement the new [VerificationController.m][1] class that Apple released to fix the in-app purchase fraud problem.

As everything released by Apple, this is one more vague, incomplete and bad explained document that lefts a lot of voids that cannot be circumvented/understood by everyone.

I am trying to implement that, 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. As my C/C++ abilities stink, I see I need to implement these two functions in C/C++ and that they must return char and void (???). Other people have posted routines to do that on SO, but they are either in Objective-C or not returning chars and void (??).

**NOTE: this is another problem I have: how can a 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);

shouldn't it be returning uint8_t?

**NOTE2: another problem I have is that apple says base64_encode is required but it is not being used on the code provided by them. I think they are smoking bad stuff or my C/C++ knowledge really stink.**

So, returning to my first question. Can someone post a method that can do the job that follows the requirements of the declared methods base64_encode and base64_decode?


Thanks.

  [1]: http://developer.apple.com/library/ios/#releasenotes/StoreKit/IAP_ReceiptValidation/_index.html


