JubeatPlus 3.9.11
Loading...
Searching...
No Matches
NSData+Base64.h File Reference

The NSData Base64 category and its two upstream C codecs. More...

import <Foundation/Foundation.h>
Include dependency graph for NSData+Base64.h:

Go to the source code of this file.

Classes

category  NSData(Base64)
 Base64 encoding and decoding for NSData, from Matt Gallagher's NSData+Base64. More...

Functions

NS_ASSUME_NONNULL_BEGIN char *_Nullable NewBase64Encode (const void *pvBuffer, size_t cbLength, size_t *_Nullable pcbOutputLength)
 Base64-encodes a byte buffer, returning a freshly allocated NUL-terminated ASCII string.
void *_Nullable NewBase64Decode (const char *pszInput, size_t cbLength, size_t *_Nullable pcbOutputLength)
 Base64-decodes an ASCII buffer, returning a freshly allocated byte buffer.

Detailed Description

The NSData Base64 category and its two upstream C codecs.

Reconstructed from Ghidra program Jubeat (image base 0x100000000). All

Ghidra address:
values are offsets relative to that image base. This is Matt Gallagher's NSData+Base64, so the two C codecs are library code, documented only to the extent needed to use them correctly. They are genuine free functions: neither takes an object receiver nor belongs to a class, and each is called only from the category methods here.

Function Documentation

◆ NewBase64Decode()

void *_Nullable NewBase64Decode ( const char * pszInput,
size_t cbLength,
size_t *_Nullable pcbOutputLength )

Base64-decodes an ASCII buffer, returning a freshly allocated byte buffer.

A cbLength of (size_t)-1 means the input is NUL-terminated and its length is measured with strlen. Invalid characters are skipped rather than rejected. The output is sized ((cbLength+3)/4)*3.

Parameters
pszInputThe Base64 text to decode.
cbLengthThe number of input bytes, or (size_t)-1 for a NUL-terminated input.
pcbOutputLengthReceives the decoded byte count when not nullptr.
Returns
The malloc'd output; the caller must free() it.
Ghidra address:
0x1adc58

◆ NewBase64Encode()

NS_ASSUME_NONNULL_BEGIN char *_Nullable NewBase64Encode ( const void * pvBuffer,
size_t cbLength,
size_t *_Nullable pcbOutputLength )

Base64-encodes a byte buffer, returning a freshly allocated NUL-terminated ASCII string.

The output is sized ((cbLength+2)/3)*4+1 and uses the standard alphabet with '=' padding. This copy is the three-argument variant with upstream's separateLines parameter stripped, so no seventy-six-column line breaks are emitted. Returns nullptr without writing anything if the allocation fails, in which case pcbOutputLength is left untouched, so a caller cannot distinguish failure from a zero-length encode.

Parameters
pvBufferThe bytes to encode.
cbLengthThe number of input bytes.
pcbOutputLengthReceives the output length excluding the NUL when not nullptr.
Returns
The malloc'd, NUL-terminated output; the caller must free() it.
Ghidra address:
0x1ade18