README.md

Mon, 07 Jun 2021 21:15:30 +0200

author
David Demelier <markand@malikania.fr>
date
Mon, 07 Jun 2021 21:15:30 +0200
changeset 36
1bf597a532fc
parent 34
e4a6c3f3d0f2
permissions
-rw-r--r--

misc: added signature for changeset 6750b0276186

19
436f5c3243bf Add C implementation
David Demelier <markand@malikania.fr>
parents: 17
diff changeset
1 libbase64 -- Base64 encoding and decoding
436f5c3243bf Add C implementation
David Demelier <markand@malikania.fr>
parents: 17
diff changeset
2 =========================================
0
a7fa8fee3d83 Initial import
David Demelier <markand@malikania.fr>
parents:
diff changeset
3
a7fa8fee3d83 Initial import
David Demelier <markand@malikania.fr>
parents:
diff changeset
4 Introduction
a7fa8fee3d83 Initial import
David Demelier <markand@malikania.fr>
parents:
diff changeset
5 ------------
a7fa8fee3d83 Initial import
David Demelier <markand@malikania.fr>
parents:
diff changeset
6
34
e4a6c3f3d0f2 misc: minor typos and changes
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
7 Base64 encoding and decoding easily in pure C89.
32
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
8
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
9 Features
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
10 --------
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
11
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
12 - base64 encoding,
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
13 - base64 decoding (with base64url support),
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
14 - no dynamic allocation required,
33
01c29bee0c54 man: add libbase64.3 manual page
David Demelier <markand@malikania.fr>
parents: 32
diff changeset
15 - only C89 required.
01c29bee0c54 man: add libbase64.3 manual page
David Demelier <markand@malikania.fr>
parents: 32
diff changeset
16 - less than 200 lines of code.
32
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
17
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
18 Quick overview
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
19 --------------
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
20
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
21 Encode data. We use -1 to read until end of input string.
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
22
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
23 char encoded[128];
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
24 size_t size;
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
25
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
26 size = b64_encode("Hello world!", -1, encoded, sizeof (encoded));
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
27
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
28 Decode data. As with previous example, we use -1 to read until enf of base64
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
29 input string.
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
30
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
31 char decoded[128];
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
32 size_t size;
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
33
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
34 size = b64_decode("ABx=", -1, decoded, sizeof (decoded));
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
35
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
36 Note: even with binary data the function `b64_decode` still append a NUL
c96f2b26678a misc: general cleanups
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
37 terminator. Use the return code from the function to get the size binary data.
33
01c29bee0c54 man: add libbase64.3 manual page
David Demelier <markand@malikania.fr>
parents: 32
diff changeset
38
01c29bee0c54 man: add libbase64.3 manual page
David Demelier <markand@malikania.fr>
parents: 32
diff changeset
39 Documentation
01c29bee0c54 man: add libbase64.3 manual page
David Demelier <markand@malikania.fr>
parents: 32
diff changeset
40 -------------
01c29bee0c54 man: add libbase64.3 manual page
David Demelier <markand@malikania.fr>
parents: 32
diff changeset
41
01c29bee0c54 man: add libbase64.3 manual page
David Demelier <markand@malikania.fr>
parents: 32
diff changeset
42 See the libbase64(3) manual page.
01c29bee0c54 man: add libbase64.3 manual page
David Demelier <markand@malikania.fr>
parents: 32
diff changeset
43
01c29bee0c54 man: add libbase64.3 manual page
David Demelier <markand@malikania.fr>
parents: 32
diff changeset
44 man ./libbase64.3

mercurial