1. 使用工具(如bc,计算机器等)把自己学号转化为16进制,提交转化过程和结果截图

2. 使用工具(如echo -e, ultraedit等)把上面转化的结果写入二进制文件“你的学号.dat”中,并用工具od -tx1 你的学号.dat
,提交命令运行

3. 使用OpenSSL的base64命令对"你的学号.dat"进行编码解码,提交过程截图

4. 使用OpenSSL编程对"你的学号.dat"进行编码解码,提交代码和运行结果截图。
#include <stdio.h>
#include <string.h>
#include <openssl/evp.h>
#include <openssl/x509.h>
void tEVP_Encode()
{
EVP_ENCODE_CTX *ctx;
ctx = EVP_ENCODE_CTX_new();
unsigned char in[1024];
int inl;
char out[2048]={0};
int outl;
FILE *infp;
FILE *outfp;
infp = fopen("20201212.dat","rb");
if(infp == NULL)
{
printf("Open File \"20201212.dat\" for Read Err.\n");
return;
}
outfp = fopen("20201212.txt","w");
if(outfp == NULL)
{
printf("Open File \"20201212.txt\" For Write Err.\n");
return;
}
EVP_EncodeInit(ctx);
printf("文件\"20201212.dat\" Base64编码后为:\n");
while(1)
{
inl = fread(in,1,1024,infp);
if(inl <= 0)
break;
EVP_EncodeUpdate(ctx,out,&outl,in,inl);
fwrite(out,1,outl,outfp);
printf("%s",out);
}
EVP_EncodeFinal(ctx,out,&outl);
fwrite(out,1,outl,outfp);
printf("%s",out);
fclose(infp);
fclose(outfp);
printf("对文件\"20201212.dat\" Base64编码完成,保存到\"20201212.txt\"文件.\n\n\n");
}
void tEVP_Decode()
{
EVP_ENCODE_CTX *ctx;
ctx = EVP_ENCODE_CTX_new();
char in[1024];
int inl;
unsigned char out[1024];
int outl;
FILE *infp;
FILE *outfp;
infp = fopen("20201212.txt","r");
if(infp == NULL)
{
printf("Open File \"20201212.txt\" for Read Err.\n");
return;
}
outfp = fopen("20201212-1.dat","wb");
if(outfp == NULL)
{
printf("Open File \"20201212-1.txt\" For Write Err.\n");
return;
}
EVP_DecodeInit(ctx);
printf("开始对文件\"20201212.txt\" Base64解码...\n\n");
while(1)
{
inl = fread(in,1,1024,infp);
if(inl <= 0)
break;
EVP_DecodeUpdate(ctx,out,&outl,in,inl);
fwrite(out,1,outl,outfp);
}
EVP_DecodeFinal(ctx,out,&outl);
fwrite(out,1,outl,outfp);
fclose(infp);
fclose(outfp);
printf("对文件\"20201212.txt\" Base64解码完成,保存为\"20201212-1.dat\"\n\n\n");
}
int main()
{
tEVP_Encode();
tEVP_Decode();
return 0;
}

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具