#include #include using namespace std; void set_passwd(); void encrypt_decrypt(ifstream&, ofstream&); int main(){ char ifile[100]; char ofile[100]; cout << "Input file to encrypt/decrypt: "; cin >> ifile; cout << "Input output file name: "; cin >> ofile; ifstream in(ifile); ofstream out(ofile); set_passwd(); encrypt_decrypt(in, out); } void set_passwd(){ char passwd[100]; long seed = 0; int shift = 0; cout << "Enter Password (100 chars max): "; cin >> passwd; for(int i = 0; i < 100 && passwd[i] != 0; i++){ seed ^= passwd[i] << shift; shift = (shift + 8)%32; } srand(seed); } void encrypt_decrypt(ifstream& in, ofstream &out){ int data; while(in.peek() != EOF){ data = in.get(); out << char(data^int(rand())); } }