非常刑
  • 板块灌水区
  • 楼主wangmengze0612
  • 当前回复9
  • 已保存回复9
  • 发布时间2025/2/5 09:47
  • 上次更新2025/2/5 13:51:34
查看原帖
非常刑
1035187
wangmengze0612楼主2025/2/5 09:47

密码破译代码

#include <iostream>
#include <string>

void brute_force(std::string &current, int max_length, const std::string &charset, const std::string &target) {
	if (current.length() == max_length) {
		return;
	}
	
	for (char c : charset) {
		current.push_back(c);
		if (current == target) {
			std::cout << "Password found: " << current << std::endl;
			return;
		}
		brute_force(current, max_length, charset, target);
		current.pop_back();
	}
}

int main() {
	std::string charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	std::string target = "abc"; // 目标密码
	std::string current;
	
	brute_force(current, 50, charset, target); // 假设密码长度为3
	return 0;
}
2025/2/5 09:47
加载中...