猫史档案馆


【加密】c++加密文件

用户:云的星云的星查看:1 回复:1 评论:1 创建时间:2021-05-24T11:25:39


代码:

#include<iostream>
#include<fstream>
#include<stack>

using namespace std;

stack<char> st;

int main(){
	char c;
	string name_in, name_out, file, line;
	cin >> name_in >> name_out;
	ifstream in(name_in.c_str());
	while(getline(in, line) && line[0] != EOF) file += line;
	cout << file.size();
	in.close();
	ofstream out(name_out.c_str());
	for(long long i = file.size() - 1;i >=0;i--) out << file[i];
	out.close();
	return 0;
}

使用方法:

输入加密前文件名与保存文件名。

注意:

程序文件与加密前文件需在同一文件夹。


回复

上一页1 页 / 共 1下一页
云的星云的星

#include<iostream>
#include<fstream>
#include<string>

using namespace std;

bool shw = 0;
string bck = "txt";

inline void init(){
	cout << "正在加载配置文件";
	ofstream out("sets");out.close();
	cout << ".";
	ifstream in("sets");
	cout << ".";
	char c;in >> c;
	if(c != '1') in >> shw >> bck;
	cout << "." <<endl;
	in.close();
	cout << "加载成功!" <<endl;
}

inline void O_(int x){
	for(int i = 0;i < x;i++) cout << '-';
}

int main_menu(){
	int ch;
	O_(37);cout << "主菜单";O_(37);
	cout << "1.加/解密" <<endl<< "2.设置" <<endl<< "3.退出程序" <<endl;
	O_(80);
	cout << "请选择" ;
	cin >> ch;
	return ch; 
}

点赞0


评论