zgh.cpp

来自「RSA加密的程序」· C++ 代码 · 共 55 行

CPP
55
字号
// zgh.cpp : Defines the entry point for the console application.
//

#include "stdio.h"
#include <string.h>

int main(int argc, char* argv[])
{
	FILE *fp,*Denstfp;
	char passwd[20];
	printf("please input passwd(4 char):");
	gets(passwd);

	fp=fopen("c:\\my.txt","rt");
	if(fp==NULL)
	{
		printf("Could not open file to read: d:\\zgh\\my.txt");
		return 0; 
	}
	Denstfp=fopen("c:\\my_pass.txt","wt");
	if(Denstfp==NULL)
	{
		fclose(fp);
		printf("Could not open file to write: d:\\zgh\\my_pass.txt");
		return 0;
	}
	while(!feof(fp))
	{
		char buff[20]="";
//..............
		fread(buff,sizeof(char),4,fp);
		buff[4]='\0';
		printf(buff);
		
		for(int i=0;i<strlen(buff);i++)
		{
			char ch=buff[i]^passwd[i];
			fflush(Denstfp);


			//fputc(ch,Denstfp);
			
			fprintf(Denstfp,"%c",ch);
		}
		//fwrite(buff,sizeof(char),4,Denstfp);
		
	}

	fclose(fp);
	fclose(Denstfp);
	printf("password success\n");
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?