代码: 全选
#ifndef _LOCK_HEADER
#define _LOCK_HEADER
void unlock(char rin[],char passwd[]);
void out(char rin[]);
void lock(char rin[],char passwd[]);
int jin(int max);
#endif /* _LOCK_HEADER */
代码: 全选
#ifndef _LOCK_HEADER
#define _LOCK_HEADER
void unlock(char rin[],char passwd[]);
void out(char rin[]);
void lock(char rin[],char passwd[]);
int jin(int max);
#endif /* _LOCK_HEADER */
谢啦!昨晚有个人帮我改了下代码!就是这样!cuihao 写了:给你一个头文件的示例:不要include"xxx.cpp",include这个头文件。代码: 全选
#ifndef _LOCK_HEADER #define _LOCK_HEADER void unlock(char rin[],char passwd[]); void out(char rin[]); void lock(char rin[],char passwd[]); int jin(int max); #endif /* _LOCK_HEADER */
代码: 全选
// MopperWhite的加密软件 bate 0.03
// 请编辑过这个文档的人在文档末端留下您的大名及大致解决的问题或增加的功能作为日志!!别忘了标日期!!!
//
// 加密bate0.03.c
//
// Copyright 2011 MopperWhite email:mopperwhite@gmail.com
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
#include <stdio.h>
#include <string.h>
#define MAXN 1000000
int myin()
{
char i;
printf("本软件暂时不能识别换行(俗称回车),请一段一段进行\n本软件能读取的内容长度仅限于%d个字节(%d个汉字)'\n由于算法不同,本软件能解密同一软件加密的数据,当然,您可以自己修改它的源码来更改算法 XD\n",MAXN,MAXN/2);
printf("请问您想加密文件还是解密文件?\n若加密请输“l”,解密请输“u”,退出请输入“e”\nYou:");
scanf("%c",&i);
if(i=='l') return 1;
else
if(i=='u') return 2;
else
if(i=='e') return 3;
else
{
printf("请再看看上面的提示!!\n");
return myin();
}
return 0;
}
void myout(char *rin)
{
char w;//结束时延迟用
printf("以下为处理结果:\n%s",rin);
printf("\n\n========================我是分割线~=========================\n为了防止终端无法显示输出字符,结果将在软件关闭后被存储在当前目录下“mout.txt”文件中\n最后说一下,本软件是开源软件,理论上您应该可以从装它的压缩包里找到源代码\n友情提示:OGC伤身体(不要深究它的意思……)\n感谢您的使用~~~~~ XD\n按回车即可退出");
scanf("%c",&w);
freopen("./mout.txt","w",stdout);
printf("%s",rin);
}
void lock(char *rin,char *passwd)
{
int n=strlen(rin);
int m=strlen(passwd);
int i,j=0;
for(i=0;i<n;i++,j++)
{
rin[i]=rin[i]+passwd[j]-43;
if(j>=m-1) j=-1;
}
myout(rin);
}
void unlock(char rin[],char passwd[])
{
int n=strlen(rin);
int m=strlen(passwd);
int i,j=0;
for(i=0;i<n;i++,j++)
{
rin[i]=rin[i]-passwd[j]+43;
if(j>=m-1) j=-1;
}
myout(rin);
}
int main(void)
{
printf("*************************************************\n本软件使用GPL协议发布,您可以随意更改、复制、使用它的源代码\n*************************************************\n\n");
char _b[10];
char rin[MAXN];
char passwd[MAXN];
int jinn=myin();
//printf("%d",myin());
if(jinn==1) sprintf(_b,"%s","加密");
else
if(jinn==2) sprintf(_b,"%s","解密");
else
if(jinn==3) return 0;
else
{
printf("起始模块发生未知错误");
return 0;
}
printf("请输入您要%s的内容,输完请按回车:\n",_b);
scanf("%s",rin);
//gets(rin);
/*int i=0;
char c;
while((c!='\0')&&(c!='\n'))
{
scanf("%c",&c);
rin[i++]=c;
}*/
//上面被注释掉的部分是为了解决输入不能带空格而写的——很明显,它失败了
printf("密码中禁止空格!\n请输入密码:");
//gets(passwd);
scanf("%s",passwd);
if(jinn==1) lock(rin,passwd);
if(jinn==2) unlock(rin,passwd);
return 0;
}
//软件生来自由!!!!!!!!
//坚定GPL一百年不动摇!!!!
//下面是日志:
//====================Bate0.02===========================================
//备注:0.02版本经过Drazet童鞋的修改与优化,谨此表达感谢!
//同时对MW的编程水平……不发表任何意见……
//重要修正:Drazet童鞋帮助解决了MW的把C存成.cpp的问题以及if后的缩进等不良习惯,同时解决了out函数不能通过编译的问题【要命的*.h啊!!!】
//还有!in和out貌似是被占用的!!
//2011/01/08
//====================Bate0.03==========================================
//MopperWhite将0.02中Drazet优化和修改的部分放进同一个文件= =#(原因么……因为MW不会写*.h……)
//貌似难度不大- -!
//纠正一个错别字~
//修正了一个因为if和else使用不当造成异常退出的BUG
//在注释中要求后面的修改者(别看了,就是你!)写日志~
//增加了文件输出(无效~)
//输入不能有空格的BUG待解决
//今天搞不定中文无法解密的问题,建议用if语句对ASCLL码较大的字符进行特殊处理(>100)
//2011/01/09
代码: 全选
// MopperWhite的加密软件 bate 0.03
// 请编辑过这个文档的人在文档末端留下您的大名及大致解决的问题或增加的功能作为日志!!别忘了标日期!!!
//
// 加密bate0.04.c
//
// Copyright 2011 MopperWhite email:mopperwhite@gmail.com
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
#include <stdio.h>
#include <string.h>
#define MAXN 1000000
int myin()
{
char i;
printf("本软件暂时不能识别换行(俗称回车)与空格\n本软件能读取的内容长度仅限于%d个字节(%d个汉字)'\n由于算法不同,本软件能解密同一软件加密的数据,当然,您可以自己修改它的源码来更改算法 XD\n",MAXN,MAXN/2);
printf("请问您想加密文件还是解密文件?\n若加密请输“l”,解密请输“u”,退出请输入“e”\nYou:");
scanf("%c",&i);
if(i=='l') return 1;
else
if(i=='u') return 2;
else
if(i=='e') return 3;
else
{
printf("请再看看上面的提示!!\n");
return myin();
}
return 0;
}
void lock(char *rin,char *passwd,char *filename)
{
int n=strlen(rin);
int m=strlen(passwd);
int i,j=0;
for(i=0;i<n;i++,j++)
{
rin[i]=rin[i]+passwd[j]-43;
if(j>=m-1) j=-1;
}
sprintf(filename,"%s%s",filename,".mout");
freopen(filename,"w",stdout);
printf("%s",rin);
}
void unlock(char *rin,char *passwd,char *filename)
{
int n=strlen(rin);
int m=strlen(passwd);
int o=strlen(filename);
char _filename[MAXN];
int i,j=0;
for(i=0;i<o-5;i++)
_filename[i]=filename[i];
for(i=0;i<n;i++,j++)
{
rin[i]=rin[i]-passwd[j]+43;
if(j>=m-1) j=-1;
}
freopen(_filename,"w",stdout);
printf("%s",rin);
}
void myout(char *filename,char *passwd,int jinn)
{
//char c;
char rin[MAXN];
//printf("以下为处理结果:\n%s",rin);
printf("\n\n========================我是分割线~=========================\n处理完毕的文件将在软件关闭后被存储在当前目录下\n最后说一下,本软件是开源软件,理论上您应该可以从装它的压缩包里找到源代码\n感谢您的使用~~~~~ XD\n");
//scanf("%c",&c);
sprintf(filename,"%s%s","./",filename);
freopen(filename,"r",stdin);
/*do
{
scanf("%c",&c);
sprintf(rin,"%s%c",rin,c);
}while(c!='\0');*/
//gets(rin);
scanf("%s",rin);
if(jinn==1) lock(rin,passwd,filename);
if(jinn==2) unlock(rin,passwd,filename);
}
int main(void)
{
printf("***********************************************************\n本软件使用GPL协议发布,您可以随意更改、复制、使用它的源代码\n***********************************************************\n\n");
char _b[10];
//char rin[MAXN];
char filename[MAXN];
char passwd[MAXN];
int jinn=myin();
//printf("%d",myin());
if(jinn==1) sprintf(_b,"%s","加密");
else
if(jinn==2) sprintf(_b,"%s","解密");
else
if(jinn==3) return 0;
else
{
printf("起始模块发生未知错误");
return 0;
}
printf("请输入您将要%s的文件放在本软件的运行目录下并输入文件名,输完请按回车:\n",_b);
scanf("%s",filename);
printf("请输入密码:");
//gets(passwd);
scanf("%s",passwd);
myout(filename,passwd,jinn);
//if(jinn==1) lock(rin,passwd);
//if(jinn==2) unlock(rin,passwd);
return 0;
}
//软件生来自由!!!!!!!!
//坚定GPL一百年不动摇!!!!
//下面是日志:
//====================Bate0.02===========================================
//备注:0.02版本经过Drazet童鞋的修改与优化,谨此表达感谢!
//同时对MW的编程水平……不发表任何意见……
//重要修正:Drazet童鞋帮助解决了MW的把C存成.cpp的问题以及if后的缩进等不良习惯,同时解决了out函数不能通过编译的问题【要命的*.h啊!!!】
//还有!in和out貌似是被占用的!!
//2011/01/08
//====================Bate0.03==========================================
//MopperWhite将0.02中Drazet优化和修改的部分放进同一个文件= =#(原因么……因为MW不会写*.h……)
//貌似难度不大- -!
//纠正一个错别字~
//修正了一个因为if和else使用不当造成异常退出的BUG
//在注释中要求后面的修改者(别看了,就是你!)写日志~
//增加了文件输出(无效~)
//输入不能有空格的BUG待解决
//今天搞不定中文无法解密的问题,建议用if语句对ASCLL码较大的字符进行特殊处理(>100)
//2011/01/09
//====================Bate0.04====================================
//修改为加密文件
//回车问题依旧……
//把“\n友情提示:OGC伤身体(不要深究它的意思……)”去掉……"OGC"本身很邪恶……
//2011/01/09
不会拆成几个.c文件,所以我一直以来都是只写一个大文件的——其实也不大~upsuper 写了:Linux Kernel 还是C和汇编写的……不能拆分的话实在难以想像那个文件的大小……cuihao 写了:你们老师没搞错把,谁说只有C++才能拆分?mopperwhite 写了:只有C++才能拆成几分cuihao 写了:LZ应该写标准的程序。
你的程序完全就是C语言的,却要cpp扩展名。
老师说我应该习惯存成cpp……
看看GTK,全用C写的.