cctools
b64.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2022 The University of Notre Dame
3 This software is distributed under the GNU General Public License.
4 See the file COPYING for details.
5 */
6 
7 #ifndef B64_H
8 #define B64_H
9 
10 #include "buffer.h"
11 
12 #include <stddef.h>
13 
25 static inline size_t b64_size (size_t bloblen)
26 {
27  /* Ceil division by 3 multiplied by 4 */
28  return 1 /* NUL byte */ + (bloblen + 3 - 1) / 3 * 4;
29 }
30 
41 int b64_encode(const void *blob, size_t bloblen, buffer_t *b64);
42 
52 int b64_decode(const char *b64, buffer_t *blob);
53 
54 #endif /* B64_H */
55 
56 /* vim: set noexpandtab tabstop=8: */
b64_encode
int b64_encode(const void *blob, size_t bloblen, buffer_t *b64)
Encode a binary blob in base64.
buffer
Definition: buffer.h:26
buffer.h
b64_decode
int b64_decode(const char *b64, buffer_t *blob)
Decode a base64 encoded blob.