title: iPhone - finalizing Apple's vague "VerificationController.m"
body: <p>I am trying to implement the new <a href="http://developer.apple.com/library/ios/#releasenotes/StoreKit/IAP_ReceiptValidation/_index.html">VerificationController.m</a> class that Apple released to fix the in-app purchase fraud problem.</p>
  
  <p>As everything released by Apple, this is one more vague, incomplete and bad explained document with a lot of voids and unknowns that cannot be circumvented/understood by everyone.</p>
  
  <p>I am trying to implement that, but at the end of the code we see these four methods:</p>
  
  <pre><code>- (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; }
  </code></pre>
  
  <p>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 (??).</p>
  
  <p><strong>NOTE: this is another problem I have: how can a method return void if it is used by Apple in this form?</strong></p>
  
  <pre><code>uint8_t *purchase_info_bytes = base64_decode([purchase_info_string cStringUsingEncoding:NSASCIIStringEncoding],                                                 &amp;purchase_info_length);
  </code></pre>
  
  <p>shouldn't it be returning uint8_t?</p>
  
  <p><strong>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.</strong></p>
  
  <p>So, returning to my first question. Can someone post/point a method that can do the job that follows the requirements of the declared methods base64_encode and base64_decode? Please refrain from posting objective-c methods that are not compatible with these requirements imposed by Apple.</p>
  
  <p>Thanks.</p>