HTML<!DOCTYPE html>
<html>
<head>
<title>简单的卡密生成</title>
<style>
body {font-family: Arial; max-width: 300px; margin: 20px auto; padding: 20px}
.box {border: 1px solid #ccc; padding: 20px; border-radius: 5px}
input {width: 100%; margin: 8px 0; padding: 8px}
button {background: #007bff; color: white; border: none; padding: 8px 15px; width: 100%}
</style>
</head>
<body>
<!-- 登录界面 -->
<div class="box" id="loginBox">
<h3>用户登录</h3>
<input type="text" id="username" placeholder="用户名">
<input type="password" id="password" placeholder="密码">
<button onclick="login()">登录</button>
<p id="loginMsg" style="color:red"></p>
</div>
<!-- 加密界面 -->
<div class="box" id="cryptoBox" style="display:none">
<h3>卡密生成</h3>
<input type="text" id="inputStr" placeholder="输入10位id">
<button onclick="encrypt()">生成</button>
<p id="result"></p>
</div>
<script>
// 用户数据
const users = {
nihao: "nihao",
zcygod: "zcygod"
};
// 登录验证
function login() {
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
if (users[username] === password) {
document.getElementById('loginBox').style.display = 'none';
document.getElementById('cryptoBox').style.display = 'block';
} else {
document.getElementById('loginMsg').textContent = '你的用户名对吗你就登录';
}
}
// Base64加密
function encrypt() {
const input = document.getElementById('inputStr').value;
const result = document.getElementById('result');
if (input.length !== 10) {
result.style.color = 'red';
result.textContent = '是id吗你就输';
return;
}
try {
let encoded = btoa(input);
// 移除末尾两个等号
encoded = encoded.replace(/==$/, '');
result.style.color = 'green';
result.textContent = `你的卡密: ${encoded}`;
} catch {
result.style.color = 'red';
result.textContent = '?你输入了什么东西';
}
}
</script>
</body>
</html>
C++#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
const string BASE64_CHARS =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
string base64_decode(const string &input) {
vector<int> decode_map(256, -1);
for (int i = 0; i < 64; ++i) {
decode_map[BASE64_CHARS[i]] = i;
}
string decoded;
int val = 0, valb = -8;
for (unsigned char c : input) {
if (decode_map[c] == -1) break;
val = (val << 6) + decode_map[c];
valb += 6;
if (valb >= 0) {
decoded.push_back(char((val >> valb) & 0xFF));
valb -= 8;
}
}
return decoded;
}
string id(int n){
string s="";
for(int i=0;i<n;i++){
if(rand()%10>=5){
s+=(char)(rand()%10+'0');
}else{
if((rand()%10)>=5){
s+=(char)(rand()%26+'a');
}else{
s+=(char)(rand()%26+'A');
}
}
}
return s;
}
int main(){
srand(time(0));
string id_a=id(10);
system("cls");
system("color 0B");
cout << "嘿嘿嘿" << endl;
cout << "dev by zcygod" << endl;
cout << "id:" << id_a << endl;
cout << "这是你的id,请你把它给zcygod,zcygod会帮你生成一个key(每次重启程序key都会刷新)" << endl;
string key;
cout << "输入key:"<< endl ;
cin >> key;
key+="==";
string temp=base64_decode(key);
if(id_a==temp){
cout << "验证成功"<<endl;
}else{
cout << "验证失败.." << endl;
system("pause");
return 0;
}
string type;
cout << "请输入你要解密的类型" << endl;
cin >> type;
string command="certutil -decode temp.txt 1."+type;
cout << "请确保当前目录下有temp.txt!" << endl;
system("pause");
system("cls");
system(command.c_str());
command="start .\\1."+type;
system(command.c_str());
system("cls");
Sleep(10000);
command="erase /q 1."+type;
system(command.c_str());
system("erase /q temp.txt");
system("cls");
system("pause");
return 0;
}