专家来解释一下这两个小程序撒
程序代码:
//图像文件加密 #include<iostream> #include<fstream> using namespace std; int main() { char ch; ifstream in; in.open("old.jpg",ios::binary); if(!in) { cout<<"Cannot open file."; return 1; } ofstream out; out.open("tmp.jpg",ios::binary); if(!out) { cout<<"Cannot open file."; return 1; } while(in) { in.get(ch); ch=ch^char(0xFF); if(in) out.put(ch); } in.close; out.close; return 0; }//图像文件解密 #include<iostream> #include<fstream> using namespace std; int main() { char ch; ifstream in; in.open("tmp.jpg",ios::binary); if(!in) { cout<<"Cannot open file."; return 1; } ofstream out; out.open("old.jpg",ios::binary); if(!out) { cout<<"Cannot open file."; return 1; } while(in) { in.get(ch); ch=ch^char(0xFF); if(in) out.put(ch); } in.close; out.close; return 0; }
谁能告诉我加密与解密的原理是什么不?