WE310F5  39.00.000
M2MB BASE64

This section describes the M2MB APIs for the BASE64 module. More...

INT32 m2mb_base64_get_encoded_output_size (INT32 input_Size)
 Get encoded output size. More...
 
M2MB_STATUS_T m2mb_base64_encode (const VOID *input_Buffer, INT32 input_Buffer_Size, CHAR *output_Buffer, INT32 output_Buffer_Size)
 Encode input data. More...
 
INT32 m2mb_base64_get_decoded_output_size (INT32 input_Size)
 Get decoded output size. More...
 
INT32 m2mb_base64_decode (const CHAR *input_Buffer, INT32 input_Buffer_Size, VOID *output_Buffer, INT32 output_Buffer_Size)
 Decode input data. More...
 

Detailed Description

This section describes the M2MB APIs for the BASE64 module.

BASE64 module provides APIs to encode and decode the date using BASE64 encoding method.

Function Documentation

◆ m2mb_base64_decode()

INT32 m2mb_base64_decode ( const CHAR input_Buffer,
INT32  input_Buffer_Size,
VOID output_Buffer,
INT32  output_Buffer_Size 
)

Decode input data.

Decodes base64 encrypted data.

Parameters
[in]input_BufferPointer to the base64 encrypted buffer to decode.
[in]input_Buffer_SizeSize of the base64 encrypted buffer to decode.
[out]output_BufferPointer to the buffer where the decoded data is to be stored.
[in]output_Buffer_SizeSize of output_buffer.
Returns
Number of bytes written into the decoded buffer.

m2mb_base64_get_encoded_output_size( input_size );

int main()
{
CHAR input[] = "YWRtaW46cGFzc3dvcmQ=", *output = NULL;
INT32 output_size = 0;
output_size = m2mb_base64_get_decoded_output_size( strlen( input ));
if (output_size == 0)
{
return M2MB_ERROR;
}
output = malloc( output_size );
if( output == NULL )
{
return M2MB_ERROR;
}
if( output_size != m2mb_base64_decode( input, strlen(input), output, output_size ))
{
return M2MB_ERROR;
}
return M2MB_OK;
}

◆ m2mb_base64_encode()

M2MB_STATUS_T m2mb_base64_encode ( const VOID input_Buffer,
INT32  input_Buffer_Size,
CHAR output_Buffer,
INT32  output_Buffer_Size 
)

Encode input data.

Encodes data using base64 encoding.

Parameters
[in]input_BufferPointer to the buffer to encode.
[in]input_Buffer_SizeSize of the buffer to encode.
[out]output_BufferPointer to the buffer where the encoded data is to be stored.
[in]output_Buffer_SizeSize of output_Buffer.
Returns
Returns M2MB_OK on success, M2MB_ERROR on failure

m2mb_base64_get_encoded_output_size( input_size );

int main()
{
CHAR input[] = "input data", *output = NULL;
INT32 output_size = 0;
output_size = m2mb_base64_get_encoded_output_size( strlen( input ));
if (output_size == 0)
{
return M2MB_ERROR;
}
output = malloc( output_size );
if( output == NULL )
{
return M2MB_ERROR;
}
status = m2mb_base64_encode( input, strlen(input), output, output_size );
return status;
}

◆ m2mb_base64_get_decoded_output_size()

INT32 m2mb_base64_get_decoded_output_size ( INT32  input_Size)

Get decoded output size.

Returns the size of the buffer needed to store base64 decoded data, given the base64 encoded data size.

Parameters
[in]input_SizeSize of the base64 encoded data
Returns
Number of bytes required to decode base64 encrypted data into.

m2mb_base64_get_encoded_output_size( input_size );

int main()
{
CHAR input[] = "YWRtaW46cGFzc3dvcmQ=";
INT32 output_size = 0;
output_size = m2mb_base64_get_decoded_output_size( strlen( input ));
if (output_size == 0)
{
return M2MB_ERROR;
}
return M2MB_OK;
}

◆ m2mb_base64_get_encoded_output_size()

INT32 m2mb_base64_get_encoded_output_size ( INT32  input_Size)

Get encoded output size.

Returns the size of the base64 encoded buffer necessary to encode input_size bytes of data.

Parameters
[in]input_SizeSize of the input data.
Returns
Number of bytes required to base64-encode the buffer of size input_size.

m2mb_base64_get_encoded_output_size( input_size );

int main()
{
CHAR input[] = "input data";
INT32 output_size = 0;
output_size = m2mb_base64_get_encoded_output_size( strlen( input ));
if (output_size == 0)
{
return M2MB_ERROR;
}
return M2MB_OK;
}