-
-
未解决 [求助]改写的base64编码部分
-
发表于: 2019-7-11 11:23 1874
-
参照了linux里面base64的设计思路,编码的时候每行76个字符。
实现的编码,和linux自带工具的base64结果不同。
下面第一部分是linux自带工具生成编码的结尾部分,第二个是自己改写的部分生成的
编码部分结尾
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuOTJVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVU=
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuOTJVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX//w==
贴上代码,不知道问题错在哪里?
void encoding(char *sourcefile,char *destfile)
{
FILE *file,*dest;
file=fopen(sourcefile,"rb");
dest=fopen(destfile,"wb");
byte f[3];
// int flag=0; // 这个是换行标志
if(file==NULL)
{
printf("Cannot open the %s file!",sourcefile);
exit(1);
}
int i=0;
int c;
int row=0; // 增加的代码,每行76个字符
while(!feof(file))
{
f[i]=fgetc(file);
i++;
if(i==3)
{
c=(f[0]>>2)&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
// writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
c=((f[0]<<4)|(f[1]>>4))&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
// writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
c=((f[1]<<2)|(f[2]>>6))&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
//writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
c=f[2]&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
//writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
i=0;
}
}
if(i==1)
{
c=(f[0]>>2)&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
//writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
c=(f[0]<<4)&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
//writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
fputc('=',dest);
row++;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
fputc('=',dest);
row++;
}
if(i==2)
{
c=(f[0]>>2)&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
// writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
c=((f[0]<<4)|(f[1]>>4))&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
//writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
c=(f[1]<<2)&60;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
//writechar(c,&flag,dest);
fputc(code[c],dest);
row++; // 增加的代码
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
fputc('=',dest); // 这句没有被执行到
row++;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
fputc('=',dest); // 这句没有被执行到
row++; // 增加的代码
}
fclose(dest);
fclose(file);
}
实现的编码,和linux自带工具的base64结果不同。
下面第一部分是linux自带工具生成编码的结尾部分,第二个是自己改写的部分生成的
编码部分结尾
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV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VVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX//w==
贴上代码,不知道问题错在哪里?
void encoding(char *sourcefile,char *destfile)
{
FILE *file,*dest;
file=fopen(sourcefile,"rb");
dest=fopen(destfile,"wb");
byte f[3];
// int flag=0; // 这个是换行标志
if(file==NULL)
{
printf("Cannot open the %s file!",sourcefile);
exit(1);
}
int i=0;
int c;
int row=0; // 增加的代码,每行76个字符
while(!feof(file))
{
f[i]=fgetc(file);
i++;
if(i==3)
{
c=(f[0]>>2)&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
// writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
c=((f[0]<<4)|(f[1]>>4))&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
// writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
c=((f[1]<<2)|(f[2]>>6))&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
//writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
c=f[2]&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
//writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
i=0;
}
}
if(i==1)
{
c=(f[0]>>2)&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
//writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
c=(f[0]<<4)&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
//writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
fputc('=',dest);
row++;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
fputc('=',dest);
row++;
}
if(i==2)
{
c=(f[0]>>2)&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
// writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
c=((f[0]<<4)|(f[1]>>4))&0x3F;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
//writechar(c,&flag,dest);
fputc(code[c],dest);
row++;
c=(f[1]<<2)&60;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
//writechar(c,&flag,dest);
fputc(code[c],dest);
row++; // 增加的代码
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
fputc('=',dest); // 这句没有被执行到
row++;
if ( row==76 )
{
fputs("\n",dest);
row = 0;
}
fputc('=',dest); // 这句没有被执行到
row++; // 增加的代码
}
fclose(dest);
fclose(file);
}
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!
赞赏
他的文章
- [求助]这个是什么壳 1531
- [求助]早期音频处理AU的1.5开放了sdk吗 1560
- 请教一个C++的编译错误 4323
- 有谁对电驴的协议有了解 3307
- [求助]vbs如何发送()键 3419
看原图
赞赏
雪币:
留言: