注:
只能在C++6.7.5运行
小助手代码:
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
// 显示带有动画效果的文本
void ccc(string s) {
for (char c : s) {
cout << c;
Sleep(50);
}
cout << endl;
}
// 加密字符串(简单的移位加密)
string encrypt(string str, int shift = 4) {
for (char &c : str) {
c += shift;
}
return str;
}
// 解密字符串
string decrypt(string str, int shift = 4) {
for (char &c : str) {
c -= shift;
}
return str;
}
// 保存用户名和密码到文件
void saveUser(const string& username, const string& password) {
ofstream file("users.txt", ios::app);
file << username << " " << encrypt(password) << endl;
file.close();
}
// 检查用户名和密码是否存在并正确
bool authenticateUser(const string& username, const string& password) {
ifstream file("users.txt");
string savedUsernam