b64.c-master
说明: Base64 encode/decode
文件列表:
.travis.yml (419, 2021-02-09)
b64.h (1694, 2021-02-09)
buffer.c (606, 2021-02-09)
clib.json (250, 2021-02-09)
CMakeLists.txt (233, 2021-02-09)
decode.c (2927, 2021-02-09)
encode.c (2148, 2021-02-09)
LICENSE (1089, 2021-02-09)
Makefile (353, 2021-02-09)
package.json (250, 2021-02-09)
test.c (1724, 2021-02-09)
b***.c
=====
Base*** encode/decode
## install
```sh
$ clib install littlstar/b***.c
```
## usage
```c
#include
```
or
```c
#include
```
```c
#include
#include
#include
#include "b***.h"
int
main (void) {
unsigned char *str = "brian the monkey and bradley the kinkajou are friends";
char *enc = b***_encode(str, strlen(str));
printf("%s\n", enc); // YnJpYW4gdGhlIG1vbmtleSBhbmQgYnJhZGxleSB0aGUga2lua2Fqb3UgYXJlIGZyaWVuZHM=
char *dec = b***_decode(enc, strlen(enc));
printf("%s\n", dec); // brian the monkey and bradley the kinkajou are friends
free(enc);
free(dec);
return 0;
}
```
## api
Base*** index table
```c
static const char b***_table[] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
};
```
Encode `unsigned char *` source with `size_t` size.
Returns a `char *` base*** encoded string
```c
char *
b***_encode (const unsigned char *, size_t);
```
Decode `char *` source with `size_t` size.
Returns a `unsigned char *` base*** decoded string
```c
unsigned char *
b***_decode (const char *, size_t);
```
## license
MIT
近期下载者:
相关文件:
收藏者: