base64解码C语言
时间: 2023-11-16 17:07:37 浏览: 135
Base64编码解码c语言实现
在C语言中,可以使用base64库来进行编码和解码操作。具体实现可以参考以下代码:
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/bio.h>
#include <openssl/evp.h>
int base64_decode(char *input, int length, char *output) {
BIO *b64, *bmem;
b64 = BIO_new(BIO_f_base64());
bmem = BIO_new_mem_buf(input, length);
bmem = BIO_push(b64, bmem);
int outlen = BIO_read(bmem, output, length);
output[outlen] = '\0';
BIO_free_all(bmem);
return outlen;
}
int main() {
char input[] = "SGVsbG8gV29ybGQh";
char output[100];
int outlen = base64_decode(input, strlen(input), output);
printf("Decoded string: %s\n", output);
return 0;
}
```
阅读全文