Base64EncodeString

Offers interface to encode/decode strings into different formats.

Summary
Base64EncodeStringOffers interface to encode/decode strings into different formats.
CopyrightThis program is free software.
Files
C-kern/api/string/base64encode_string.hHeader file Base64EncodeString.
C-kern/string/base64encode_string.cImplementation file Base64EncodeString impl.
Base64Encoding.All functions assumes that strings are utf8 encoded.
Functions
test
unittest_string_base64encodeTest encoding/decoding of strings.
string_t
query
sizebase64encode_stringReturns the size of the encoded string.
sizebase64decode_stringReturns the size of the decoded string.
base64encoding
base64encode_stringEncodes string str in Base64 format.
base64decode_stringDecodes string str from Base64 into a binary octet stream.
inline implementation
Macros
sizebase64encode_stringImplements string_t.sizebase64encode_string.

Copyright

This program is free software.  You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Author

© 2011 Jörg Seebohn

Files

C-kern/api/string/base64encode_string.h

Header file Base64EncodeString.

C-kern/string/base64encode_string.c

Implementation file Base64EncodeString impl.

Base64Encoding.

All functions assumes that strings are utf8 encoded.

Functions

Summary
test
unittest_string_base64encodeTest encoding/decoding of strings.

test

unittest_string_base64encode

int unittest_string_base64encode(void)

Test encoding/decoding of strings.

string_t

Summary
query
sizebase64encode_stringReturns the size of the encoded string.
sizebase64decode_stringReturns the size of the decoded string.
base64encoding
base64encode_stringEncodes string str in Base64 format.
base64decode_stringDecodes string str from Base64 into a binary octet stream.

query

sizebase64encode_string

size_t sizebase64encode_string(const struct string_t *str)

Returns the size of the encoded string.  The encoded size is 4/3 of the orginal size.  If the size is not a multiple of 3 then it is rounded up to the next higher value which is a multiple of 3.

sizebase64decode_string

size_t sizebase64decode_string(const struct string_t *str)

Returns the size of the decoded string.  The decoded size is 3/4 of the orginal size minus 0, 1, or 2.

base64encoding

base64encode_string

int base64encode_string(const struct string_t *str,
/*ret*/struct wbuffer_t *result)

Encodes string str in Base64 format.  The encoded size is 4/3 of the orginal size.  If the size is not a multiple of 3 then it is rounded up to the next higher value which is a multiple of 3.

base64decode_string

int base64decode_string(const struct string_t *str,
/*ret*/struct wbuffer_t *result)

Decodes string str from Base64 into a binary octet stream.  The decoded size is 3/4 of the orginal size.  EINVAL is returned if the encoded size is not a multiple of 4.

Macros

sizebase64encode_string

#define sizebase64encode_string(str) (4 * ((2 + (str)->size)/3))

Implements string_t.sizebase64encode_string.

Offers interface to encode/decode strings into different formats.
Implements Base64EncodeString.
int unittest_string_base64encode(void)
Test encoding/decoding of strings.
size_t sizebase64encode_string(const struct string_t *str)
Returns the size of the encoded string.
size_t sizebase64decode_string(const struct string_t *str)
Returns the size of the decoded string.
int base64encode_string(const struct string_t *str,
/*ret*/struct wbuffer_t *result)
Encodes string str in Base64 format.
int base64decode_string(const struct string_t *str,
/*ret*/struct wbuffer_t *result)
Decodes string str from Base64 into a binary octet stream.
#define sizebase64encode_string(str) (4 * ((2 + (str)->size)/3))
Implements string_t.sizebase64encode_string.
Close