Skip to content

kevinAlbs/libbase122

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e71b8a6 · Jan 13, 2024

History

80 Commits
Jan 4, 2024
Jan 13, 2024
Oct 10, 2022
Oct 10, 2022
Dec 11, 2023
Jan 4, 2024
Aug 29, 2022
Aug 29, 2022
Jan 4, 2024
Oct 11, 2022
Jan 4, 2024

Repository files navigation

libbase122

libbase122 is a C89 library for encoding and decoding Base122.

libbase122 compiles with -std=c89.

This repository includes b122, an application for encoding and decoding Base122.

Usage

Usage of libbase122:

#include "base122.h"
#include <stdio.h>

int main(void) {
  unsigned char *data = (unsigned char *)"\x34\x19\x2d\x46\x63\x3c\x14";
  unsigned char decoded[16] = {0};
  base122_error_t error;
  int got;
  size_t written;

  got = base122_decode(data, 8, decoded, sizeof(decoded), &written, &error);

  if (got == -1) {
    fprintf(stderr, "Error decoding: %s\n", error.msg);
    return 1;
  }
  printf("Decoded the string: %s\n", decoded);
  return 0;
}

Usage of b122:

cat example.jpg | b122 > encoded.b122
cat encoded.b122 | b122 -d > decoded.jpg

Using with CMake

CMake targets are exported. To use libbase122 in a CMake project:

add_executable (app app.c)
find_package (Base122 REQUIRED)
target_link_libraries (app base122::static) # Or base122::shared

Contributing

Contributions are welcome.

GitHub actions is used to compile and test each commit. See cmake.yml for the platform specific C flags.

Tests may be run locally with:

cmake -S. -Bcmake-build
cmake --build cmake-build --target test-libbase122
./cmake-build/test-libbase122