1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 * The apr_vsnprintf/apr_snprintf functions are based on, and used with the
16 * permission of, the SIO stdio-replacement strx_* functions by Panos
17 * Tsirigotis <panos@alumni.cs.colorado.edu> for xinetd.
22 * @brief APR-UTIL Base64 Encoding
28 #include "apr_general.h"
35 * @defgroup APR_Util_Base64 Base64 Encoding
40 /* Simple BASE64 encode/decode functions.
42 * As we might encode binary strings, hence we require the length of
43 * the incoming plain source. And return the length of what we decoded.
45 * The decoding function takes any non valid char (i.e. whitespace, \0
46 * or anything non A-Z,0-9 etc as terminal.
48 * plain strings/binary sequences are not assumed '\0' terminated. Encoded
49 * strings are neither. But probably should.
54 * Given the length of an un-encoded string, get the length of the
56 * @param len the length of an unencoded string.
57 * @return the length of the string after it is encoded, including the
60 APU_DECLARE(int) apr_base64_encode_len(int len);
63 * Encode a text string using base64encoding.
64 * @param coded_dst The destination string for the encoded string.
65 * @param plain_src The original string in plain text
66 * @param len_plain_src The length of the plain text string
67 * @return the length of the encoded string
69 APU_DECLARE(int) apr_base64_encode(char * coded_dst, const char *plain_src,
73 * Encode an EBCDIC string using base64encoding.
74 * @param coded_dst The destination string for the encoded string.
75 * @param plain_src The original string in plain text
76 * @param len_plain_src The length of the plain text string
77 * @return the length of the encoded string
79 APU_DECLARE(int) apr_base64_encode_binary(char * coded_dst,
80 const unsigned char *plain_src,
84 * Determine the maximum buffer length required to decode the plain text
85 * string given the encoded string.
86 * @param coded_src The encoded string
87 * @return the maximum required buffer length for the plain text string
89 APU_DECLARE(int) apr_base64_decode_len(const char * coded_src);
92 * Decode a string to plain text
93 * @param plain_dst The destination string for the plain text
94 * @param coded_src The encoded string
95 * @return the length of the plain text string
97 APU_DECLARE(int) apr_base64_decode(char * plain_dst, const char *coded_src);
100 * Decode an EBCDIC string to plain text
101 * @param plain_dst The destination string for the plain text
102 * @param coded_src The encoded string
103 * @return the length of the plain text string
105 APU_DECLARE(int) apr_base64_decode_binary(unsigned char * plain_dst,
106 const char *coded_src);
113 #endif /* !APR_BASE64_H */