本人近期在做国创项目,其中需要使用重复码,并且使用经过重复码编码后的数据进行加密。
问题是重复码编码后再读取就乱码了,而且我不知道怎么样可以读取出二进制数据
重复码代码如下:
-
-
-
-
-
-
-
-
static unsigned int inbfr,outbfr;
-
static FILE *outfile,*infile;
-
static int incnt,outcnt,mask;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
outbfr = (outbfr<<1)&255;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
for (int i=0;i<outcnt;i++)
-
-
-
-
-
-
-
-
-
-
if ((infile = fopen("ciphertext.txt", "rb")) == NULL)
-
-
printf("cannot open infile!!!n");
-
-
-
if ((outfile = fopen("decryption.txt", "wb")) == NULL)
-
-
printf("cannot open outfile!!!n");
-
-
-
-
-
-
-
-
for (int i = 0; i < n; i++) bitsum += getbit();
-
if (bitsum >= 2) putbit(1);
-
-
-
-
-
-
-
-
-
-
-
-
-
if((infile=fopen("plaintext.txt","rb"))==NULL)
-
-
-
-
-
ofstream file_writer("plaintext.txt", ios_base::out);
-
-
-
-
-
-
if ((infile = fopen("plaintext.txt", "w+")) != NULL)
-
-
-
-
-
ofstream file_writer("plaintext.txt", ios_base::out);
-
-
-
-
-
-
if((outfile=fopen("ciphertext.txt","wb"))==NULL)
-
-
ofstream infile("ciphertext.txt");
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
ifstream in("ciphertext.txt");
-
-
while (getline(in, str));
-
cout << "重复码编码后的内容: " << str << endl;
-
-
-
-
-
-
-
-
-
-
-
乱码截图如下:
我试过网上的读取方法,我用的都不适用。
我想读取重复码编码后的二进制数据,最好是用十进制表示的二进制数 ,因为后续还要加密(例如 2 表示为 十进制的10)。求各位大佬帮助!
原文链接: https://www.cnblogs.com/MoRanPiao/p/16772707.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/5519
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!