utils_base64.h 1.3 KB
Newer Older
W
WangFengTu 已提交
1 2
/******************************************************************************
 * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
3 4 5 6
 * iSulad licensed under the Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *     http://license.coscl.org.cn/MulanPSL2
W
WangFengTu 已提交
7 8 9
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
 * PURPOSE.
10
 * See the Mulan PSL v2 for more details.
W
WangFengTu 已提交
11
 * Author: wangfengtu
W
WangFengTu 已提交
12 13 14 15
 * Create: 2020-03-26
 * Description: provide base64 functions
 ********************************************************************************/

16 17
#ifndef UTILS_CUTILS_UTILS_BASE64_H
#define UTILS_CUTILS_UTILS_BASE64_H
W
WangFengTu 已提交
18 19

#include <stdbool.h>
20
#include <stddef.h>
W
WangFengTu 已提交
21 22 23 24 25 26 27
#include <stdint.h>
#include <sys/types.h>

#ifdef __cplusplus
extern "C" {
#endif

W
WangFengTu 已提交
28 29 30 31 32
int util_base64_encode(unsigned char *bytes, size_t len, char **out);

// note: The result out put will be *out_len + 1, and it's filled with '\0', so if the decoded
//       data is a string, it's safe to use it as a string.
int util_base64_decode(const char *input, size_t len, unsigned char **out, size_t *out_len);
W
WangFengTu 已提交
33 34 35 36 37

#ifdef __cplusplus
}
#endif

38
#endif // UTILS_CUTILS_UTILS_BASE64_H