代码实例
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
using namespace std;
// 逆序加密函数
string reverseEncrypt(string text) {
reverse(text.begin(), text.end());
return text;
}
int main() {
ifstream inputFile("1.txt");
ofstream outputFile("1_encrypted.txt");
if (!inputFile) {
cerr << "无法打开文件 1.txt" << endl;
return 1;
}
string content((istreambuf_iterator<char>(inputFile)), istreambuf_iterator<char>());
string encrypted = reverseEncrypt(content);
outputFile << encrypted;
cout << "加密完成,结果保存在 1_encrypted.txt 中" << endl;
inputFile.close();
outputFile.close();
return 0;
}
加密过程和原理
将文本字符顺序反转。
标签:加密,Reverse,text,Cipher,inputFile,include,string,逆序 From: https://www.cnblogs.com/o-O-oO/p/18660051