Main Page Modules Data Structures File List Data Fields Globals Related Pages

# beecrypt/base64.c File Reference

Base64 encoding/decoding, code. More...

`#include "system.h"`
`#include "base64.h"`
`#include "debug.h"`

Go to the source code of this file.

## Defines
#define | CHARS_PER_LINE 64
#define | CRC24_INIT 0xb704ceL
#define | CRC24_POLY 0x1864cfbL
## Functions
char * | b64enc (const memchunk *chunk)
memchunk * | b64dec (const char *string)
char * | b64encode (const void *data, int ns)
| Encode chunks of 3 bytes of binary input into 4 bytes of base64 output. More...
char * | b64crc (const unsigned char *data, int ns)
| Encode crc of binary input data into 5 bytes of base64 output. More...
int | b64decode (const char *s, void **datap, int *lenp)
| Decode chunks of 4 bytes of base64 input into 3 bytes of binary output. More...
## Variables
int | _debug = 0
const char * | to_b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
int | b64encode_chars_per_line = 72
| Encode 72 characters per line (default). More...
const char * | b64encode_eolstr = "\n"
| Encode end-of-line string (default). More...
const char * | b64decode_whitespace = " \f\n\r\t\v"
| Decode white space character set (default). More...

## Detailed Description

Base64 encoding/decoding, code.

Definition in file base64.c.

## Define Documentation

#define CHARS_PER_LINE 64

| Definition at line 39 of file base64.c. Referenced by b64enc.

#define CRC24_INIT 0xb704ceL

| Definition at line 334 of file base64.c. Referenced by b64crc.

#define CRC24_POLY 0x1864cfbL

| Definition at line 335 of file base64.c. Referenced by b64crc.

## Function Documentation

char* b64crc | ( | const unsigned char * | data,
|  | int | ns
| ) |

  | Encode crc of binary input data into 5 bytes of base64 output. Parameters:
  data | binary data
  ns | crc of data
Returns: (malloc'd) base64 string Definition at line 338 of file base64.c. References b64encode, CRC24_INIT, CRC24_POLY, swapu32, and uint32.

memchunk* b64dec | ( | const char * |  | ) |

| Definition at line 106 of file base64.c. References memchunk::data, memchunkAlloc, and to_b64.

int b64decode | ( | const char * | s,
|  | void ** | datap,
|  | int * | lenp
| ) |

  | Decode chunks of 4 bytes of base64 input into 3 bytes of binary output. Parameters:
  s | base64 string
  Return values:
  datap | address of (malloc'd) binary data
  lenp | address of no. bytes of binary data
Returns: 0 on success, 1: s == NULL, 2: bad length, 3: bad char Definition at line 370 of file base64.c. References b64decode_whitespace.

char* b64enc | ( | const memchunk * |  | ) |

| Definition at line 42 of file base64.c. References CHARS_PER_LINE, memchunk::data, memchunk::size, and to_b64. Referenced by b64encode.

char* b64encode | ( | const void * | data,
|  | int | ns
| ) |

  | Encode chunks of 3 bytes of binary input into 4 bytes of base64 output. Parameters:
  data | binary data
  ns | no. bytes of data (0 uses strlen(data))
Returns: (malloc'd) base64 string Definition at line 249 of file base64.c. References b64enc, b64encode_chars_per_line, and b64encode_eolstr.

## Variable Documentation

int _debug = 0`[static]`

| Definition at line 33 of file base64.c.

const char* b64decode_whitespace = " \f\n\r\t\v"

| Decode white space character set (default). Definition at line 366 of file base64.c. Referenced by b64decode.

int b64encode_chars_per_line = 72

| Encode 72 characters per line (default). Definition at line 243 of file base64.c. Referenced by b64encode.

const char* b64encode_eolstr = "\n"

| Encode end-of-line string (default). Definition at line 245 of file base64.c. Referenced by b64encode.

const char* to_b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"`[static]`

| Definition at line 36 of file base64.c. Referenced by b64dec, and b64enc.