一个异或加密方案--C语言实现

核心代码:

char encrypt( char f , char c)
{
	return f^c;
}
 int OutEncrypt( char *FilePath, char *SecretWord )
{
	FILE *  fp ;
	FILE * fp1;
	char *p= FilePath , *s= SecretWord;
	//char fn[128], *p = fn, ps[10], *s = ps;   //fn[128]存放加密文件路径,ps[10]存放密码
	char ch;
	char *tm = "C:\temp.temp";   //存放临时文件

	if(( fp = fopen(p,"rb") )== NULL || ( fp1 = fopen(tm,"wb") ) == NULL )
	{
		return 0;    //加密失败
	}

	ch = fgetc(fp);
	while( !feof(fp) )
	{
		s = SecretWord;
		while( *s != '' )
		{
			ch = encrypt( ch, *s++ );
			fputc( ch, fp1 );
			ch = fgetc(fp);
		}
	}
	fclose( fp );
	fclose( fp1);
	remove(p);
	rename(tm, p);

	return 1;   //加密成功
}


可以将此加密方案做成.dll格式用于其它项目使用,如:C#,Windows编程,MFC编程中

创建.dll工程下载地址:http://download.csdn.net/detail/qq2399431200/6274867







原文地址:https://www.cnblogs.com/keanuyaoo/p/3325005.html