crypto.cpp

来自「使用XOR算法进行加解密」· C++ 代码 · 共 46 行

CPP
46
字号
#include <iostream.h>
#include <stdlib.h>
#include <fstream.h>

void Encrypt(char *file1)
   {
   	int crypto;
      char x;
      ifstream in_file;
      ofstream out_file;
      in_file.open(file1);
      if(in_file.fail())
      {
      	cout <<"\nError opening the file"<<file1
         <<"check that the file currently exists."<<endl;
         exit(1);
      }
      cout <<"Enter a name for the Encrypted file:";
      cin  >>file1;
      out_file.open(file1);
      in_file.get (x);
      if (in_file.eof())
      	return;
      while (x !=EOF)
      {
      crypto=x-0xFACA-0xFACA;
      out_file<<(char)crypto;
      in_file.get (x);
      if (in_file.eof())
      	break;
      }
      in_file.close();
      out_file.close();
      return;
	}

int main()
{
	const int MAXLENGHT=25;
   char file1[MAXLENGHT];
   ifstream in_file;
   cout <<"Enter the name of the file you wish to Encrypt:";
   cin >>file1;
   Encrypt(file1);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?