写一个Linux下包含中文的base64解码代码
时间: 2024-05-05 17:17:54 浏览: 86
支持中文的base64编码文件
好的,以下是在Linux下包含中文的base64解码代码:
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/bio.h>
#include <openssl/evp.h>
char* base64_decode(const char* input, int length) {
BIO* b64 = BIO_new(BIO_f_base64());
BIO* bmem = BIO_new(BIO_s_mem());
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
BIO_push(b64, bmem);
BIO_write(bmem, input, length);
BIO_flush(bmem);
char* output = (char*)malloc(length);
int len = BIO_read(b64, output, length);
output[len] = '\0';
BIO_free_all(b64);
return output;
}
int main() {
char input[] = "5oiR5piv5L2g5aW977yM5Lu25oiW55qE5ZCM6K6k5L2V5LiA5Liq5o6o5Lya5YWo5L2c5oiQ5YyW5Y+K5Lq65Lq66K+V5pWw5YyX";
char* output = base64_decode(input, strlen(input));
printf("Decoded text: %s\n", output);
free(output);
return 0;
}
```
请问还有其他问题吗?
阅读全文