1 Star 0 Fork 0

wwwsh0510/博物馆讲解系统

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
utils.c 846 Bytes
一键复制 编辑 原始数据 按行查看 历史
wwwsh0510 提交于 2024-07-05 15:00 . 增加解码函数
#include <stdio.h>
#include <uuid/uuid.h>
#include <resolv.h> //b64_pton
#include <string.h>
//生成UUID
char* gen_uuid(void)
{
static char uuid_str[37];
uuid_t uuid;
uuid_generate(uuid);
uuid_unparse(uuid, uuid_str);
return uuid_str;
}
// base64解码
//base64: 需要解码的base64字符串
//decoded: 解码后的数据
//返回值: 解码后的数据大小
size_t base64_decode(const char* base64, char* decoded)
{
// 计算解码后的数据大小
size_t decoded_size = (strlen(base64) / 4 + 1) * 3;
// 解码base64字符串
int size = b64_pton(base64, decoded, decoded_size);
if (size < 0)
{
return 0;
}
return size;
}
int main()
{
puts(gen_uuid());
char text[100];
int size = base64_decode("6YGT5Y+v6YGT6Z2e5bi46YGT", text);
printf("%*s\n", size, text);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wwwsh0510/museum-self-explanation-system.git
git@gitee.com:wwwsh0510/museum-self-explanation-system.git
wwwsh0510
museum-self-explanation-system
博物馆讲解系统
master

搜索帮助