最近开始重学c++,
也是第一次博客 暂且来试试水吧
首先打算用c++写个简单的文档加密算法(当然只是初级的,能够读取txt文本然后简单加密解密一下就行了
--------------------------------------------------------------------------------------------------------------------------------------------
#include<windows.h>
#include<fstream.h>
void encryption(char *c,int n);//加密
void deciphering(char *,int );//解密
int main()
{
char buff2[100];
fstream wf("c:\\local.txt",ios::out|ios::in);
streampos po=wf.tellg();
wf.seekg(0);
cout<<' ';
while(wf.eof())
{
po=wf.tellg();
wf.getline(buff2,100);
cout<<buff2<<endl;
deciphering(buff2,100);
cout<<buff2<<endl;
wf.seekg(po);
wf << buff2<<"\n";//即使是写入也会使指针后移一行
}
return 0;
}
void encryption(char *c ,int n )
{
int max=strlen(c);
for(int i=0;i<max;i++)
{
c[i]+='王';
}
}
void deciphering(char *c ,int n)
{
int max=strlen(c);
for(int i=0;i<max;i++)
{
c[i]-='王';
}
}