Skip to content

ambitslix/base64

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Base64 stream encoder/decoder in C89

This is an implementation of a base64 stream encoder/decoder in C89. It also contains wrapper functions to encode/decode simple length-delimited strings.

Notable features:

  • Reads/writes blocks of streaming data;
  • Does not dynamically allocate memory;
  • Valid C89 that compiles with pedantic options on;
  • Unit tested;
  • Fairly fast;
  • Uses Duff's Device.

The stream encoder/decoders made reentrant with BASE64_STATE.

The API itself is documented in base64.h.

Examples

A simple example of encoding a static string to base64 and printing the output to stdout:

#include <stdio.h>	/* fwrite */
#include "base64.h"

int main ()
{
	char src[] = "hello world";
	char out[20];
	size_t srclen = sizeof(src) - 1;
	size_t outlen;

	base64_encode(src, srclen, out, &outlen);

	fwrite(out, outlen, 1, stdout);

	return 0;
}

License

This repository is licensed under the BSD 2-clause License. See the LICENSE file.

About

Base64 stream encoder/decoder in C89

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 100.0%