Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8283615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:47:47+00:00 2026-06-08T10:47:47+00:00

I am trying to implement the new VerificationController.m class that Apple released to fix

  • 0

I am trying to implement the new VerificationController.m 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 with a lot of voids and unknowns 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/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.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:47:48+00:00Added an answer on June 8, 2026 at 10:47 am

    This solution should be pretty straight forward, which includes all the methods to populate the missing information. Tested and functional within the sandbox.

    //  single base64 character conversion
    static int POS(char c)
    {
        if (c>='A' && c<='Z') return c - 'A';
        if (c>='a' && c<='z') return c - 'a' + 26;
        if (c>='0' && c<='9') return c - '0' + 52;
        if (c == '+') return 62;
        if (c == '/') return 63;
        if (c == '=') return -1;
    
        [NSException raise:@"invalid BASE64 encoding" format:@"Invalid BASE64 encoding"];
        return 0;
    }
    
    - (NSString *)encodeBase64:(const uint8_t *)input length:(NSInteger)length
    {
        return [NSString stringWithUTF8String:base64_encode(input, (size_t)length)];
    }
    
    - (NSString *)decodeBase64:(NSString *)input length:(NSInteger *)length
    {
        size_t retLen;
        uint8_t *retStr = base64_decode([input UTF8String], &retLen);
        if (length)
            *length = (NSInteger)retLen;
        NSString *st = [[[NSString alloc] initWithBytes:retStr
                                                 length:retLen
                                               encoding:NSUTF8StringEncoding] autorelease];
        free(retStr);    // If base64_decode returns dynamically allocated memory
        return st;
    }
    
    char* base64_encode(const void* buf, size_t size)
    {
        static const char base64[] =  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    
        char* str = (char*) malloc((size+3)*4/3 + 1);
    
        char* p = str;
        unsigned char* q = (unsigned char*) buf;
        size_t i = 0;
    
        while(i < size) {
            int c = q[i++];
            c *= 256;
            if (i < size) c += q[i];
            i++;
    
            c *= 256;
            if (i < size) c += q[i];
            i++;
    
            *p++ = base64[(c & 0x00fc0000) >> 18];
            *p++ = base64[(c & 0x0003f000) >> 12];
    
            if (i > size + 1)
                *p++ = '=';
            else
                *p++ = base64[(c & 0x00000fc0) >> 6];
    
            if (i > size)
                *p++ = '=';
            else
                *p++ = base64[c & 0x0000003f];
        }
    
        *p = 0;
    
        return str;
    }
    
    void* base64_decode(const char* s, size_t* data_len_ptr)
    {
        size_t len = strlen(s);
    
        if (len % 4)
            [NSException raise:@"Invalid input in base64_decode" format:@"%d is an invalid length for an input string for BASE64 decoding", len];
    
        unsigned char* data = (unsigned char*) malloc(len/4*3);
    
        int n[4];
        unsigned char* q = (unsigned char*) data;
    
        for(const char*p=s; *p; )
        {
            n[0] = POS(*p++);
            n[1] = POS(*p++);
            n[2] = POS(*p++);
            n[3] = POS(*p++);
    
            if (n[0]==-1 || n[1]==-1)
                [NSException raise:@"Invalid input in base64_decode" format:@"Invalid BASE64 encoding"];
    
            if (n[2]==-1 && n[3]!=-1)
                [NSException raise:@"Invalid input in base64_decode" format:@"Invalid BASE64 encoding"];
    
            q[0] = (n[0] << 2) + (n[1] >> 4);
            if (n[2] != -1) q[1] = ((n[1] & 15) << 4) + (n[2] >> 2);
            if (n[3] != -1) q[2] = ((n[2] & 3) << 6) + n[3];
            q += 3;
        }
    
        // make sure that data_len_ptr is not null
        if (!data_len_ptr)
            [NSException raise:@"Invalid input in base64_decode" format:@"Invalid destination for output string length"];
    
        *data_len_ptr = q-data - (n[2]==-1) - (n[3]==-1);
    
        return data;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to implement google C2DM service. registrationIntent.putExtra(app, PendingIntent.getBroadcast(context,0,new Intent(), 0)); registrationIntent.putExtra(sender,example@gmail.com); context.startService(registrationIntent); Almost every
I am trying to implement a new class inherited from List<string> , to load
Hi Im new to PHP and trying to implement a class. Inside the class
I'm new to C++ and trying to implement a turtle emulator that will read
I am new to Android and trying to implement the sample AlarmController application. Everything
I am trying to implement a function that will insert a new entry in
Basically I am trying to implement a login such as that of the new
I'm trying to implement the new oAuth2 facebook SDK into my app but can't
Trying to implement a function in my linkedlist class that will return total amount
I'm trying to implement a timer into a new application. One use case that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.