- #include<iostream>
- using namespace std;
- void main()
- {
- char x='A',y,z; //x为密码,y为要加密的文件
- cout<<"输入要加密的字母:"<<endl;
- cin>>y;
- y=y^x; //对y进行加密
- cout<<"加密后的y:"<<endl;
- cout<<int(y)<<endl;
- cout<<"输入密码:"<<endl;
- cin>>z;
- while(z!='A')
- {
- cout<<"密码错误 !"<<endl;
- cout<<"重新输入密码:"<<endl;
- cin>>z;
- }
- cout<<"解密后的y:"<<endl<<char(y^z)<<endl;
- }
复制代码
|