https://github.com/paolostivanin/libbaseencode
Library written in C for encoding and decoding data using base32 or base64 (RFC-4648)
https://github.com/paolostivanin/libbaseencode
base32 base64 c
Last synced: 27 days ago
JSON representation
Library written in C for encoding and decoding data using base32 or base64 (RFC-4648)
- Host: GitHub
- URL: https://github.com/paolostivanin/libbaseencode
- Owner: paolostivanin
- License: apache-2.0
- Archived: true
- Created: 2017-03-29T16:53:29.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-10T08:28:58.000Z (over 2 years ago)
- Last Synced: 2024-11-18T23:51:02.489Z (7 months ago)
- Topics: base32, base64, c
- Language: C
- Size: 89.8 KB
- Stars: 21
- Watchers: 4
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# libbaseencode (deprecated since libcotp 2.0.0)
![]()
Library written in C for encoding and decoding data using base32 or base64 according to [RFC-4648](https://tools.ietf.org/html/rfc4648)
⚠️ libbasencode is deprecated since [libcotp](https://github.com/paolostivanin/libcotp) 2.0.0 has been released. ⚠️
# Requiremens
- GCC or Clang
- CMake# Build and Install
```
$ git clone https://github.com/paolostivanin/libbaseencode.git
$ cd libbaseencode
$ mkdir build && cd $_
$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ../
$ make
# make install
```# How To Use It
```
char *b32_encoded = base32_encode(unsigned char *input, size_t input_length, baseencode_error_t *err);unsigned char *b32_decoded = base32_decode(char *input, size_t input_length, baseencode_error_t *err);
char *b64_encoded = base64_encode(unsigned char *input, size_t input_length, baseencode_error_t *err);
unsigned char *b64_decoded = base64_decode(char *input, size_t input_length, baseencode_error_t *err);
```
Please note that all the returned value **must be freed** once not needed any more.## Errors
In case of errors, `NULL` is returned and `err` is set to either one of:
```
INVALID_INPUT, EMPTY_STRING, INPUT_TOO_BIG, INVALID_B32_DATA, INVALID_B64_DATA, MEMORY_ALLOCATION,
```
otherwise, `err` is set to `SUCCESS`