addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const html = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>密码、UUID生成器</title>
<link rel="shortcut icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2280%22>💠</text></svg>">
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-image: url('https://xxq.dpdns.org/');
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
}
.sites {
width:345px;
background-color: rgba(211, 211, 211, 0.4); /* 80% 透明度 */
border:1px solid rgba(0,0,0,.16);
margin:10px auto;
padding:6px;
}
.header, .links {
width: auto;
text-align: center;
}
.footer{
color: white;
width:auto;
text-align:center;
margin:2px auto;
padding:1px;
border-radius: 10px; /* 四角弧度,一般高为5,50为圆*/
}
.avatar {
border-radius: 50%;
width: 80px;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
flex-direction: column;
}
.password {
font-size: 15px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: rgba(211, 211, 211, 0.6); /* 50% 透明度 */
margin-top: 20px;
min-width: 100px;
max-width: 340px;
min-height: 48px;
text-align: left;
white-space: pre-line;
}
button {
padding: 8px 22px;
background-color: #4285f4;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
margin: 10px;
font-size: 18px;
}
.button-container {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
}
.button-container button {
margin: 0 6px;
font-size: 14px;
}
.option-row {
display: flex;
justify-content: space-between;
width: 340px;
margin-bottom: 12px;
}
label {
font-size: 18px;
display: flex;
align-items: center;
width: 48%;
}
input[type=checkbox] {
transform: scale(1.5);
margin-left: 10px;
}
input[type=number] {
width: 40px;
}
.progress-bar {
height: 20px;
width: 100%;
background: #ddd;
border-radius: 10px;
overflow: hidden;
margin-bottom: 10px;
}
.progress {
height: 100%;
width: 0%;
transition: width 0.3s ease;
}
.score {
font-weight: bold;
margin-top: 10px;
}
.advice {
margin-top: 15px;
text-align: left;
font-size: 14px;
background-color: rgba(255, 255, 255, 0.7);
padding: 10px;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<a href="https://www.199881.xyz" target="_blank">
<img class="avatar" src="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2280%22>💠</text></svg>"/>
</a>
<div class="sites">
<h2>生成随机密码和UUID</h2>
<div class="option-row">
<label>大写(A-Z) <input type="checkbox" id="includeUppercase" checked></label>
<label>小写(a-z) <input type="checkbox" id="includeLowercase" checked></label>
</div>
<div class="option-row">
<label>数字(0-9) <input type="checkbox" id="includeNumbers" checked></label>
<label>排除l10o <input type="checkbox" id="excludeCharacters"></label>
</div>
<div class="option-row">
<label>部份字符 <input type="checkbox" id="includeSpecial1"></label>
<label>全部字符 <input type="checkbox" id="includeSpecial2"></label>
</div>
<div class="option-row">
<label for="passwordCount">生成个数 <input type="number" id="passwordCount" value="1" min="1" max="10"></label>
<label for="passwordLength">密码长度 <input type="number" id="passwordLength" value="16" min="6" max="32"></label>
</div>
<!-- 生成密码、UUID和复制按钮 -->
<div class="button-container">
<button onclick="generatePassword()">生成密码</button>
<button onclick="generateUUIDs()">生成UUID</button>
<button onclick="copyPassword()">复制</button>
</div>
<div class="password" id="passwordDisplay"></div>
<div class="progress-bar"><div class="progress" id="progress"></div></div>
<div class="score" id="score">安全得分: 0 / 100</div>
<div class="advice" id="advice"></div>
</div>
<script>
function generatePassword() {
const length = document.getElementById('passwordLength').value;
const count = document.getElementById('passwordCount').value;
const includeUppercase = document.getElementById('includeUppercase').checked;
const includeLowercase = document.getElementById('includeLowercase').checked;
const includeNumbers = document.getElementById('includeNumbers').checked;
const includeSpecial1 = document.getElementById('includeSpecial1').checked;
const includeSpecial2 = document.getElementById('includeSpecial2').checked;
const excludeCharacters = document.getElementById('excludeCharacters').checked;
let charset = '';
if (includeUppercase) charset += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
if (includeLowercase) charset += 'abcdefghijklmnopqrstuvwxyz';
if (includeNumbers) charset += '0123456789';
if (includeSpecial1) charset += '!#$%^&*_<>';
if (includeSpecial2) charset += '!@#$%^&*()_+{}|:<>?-=[];,./';
if (excludeCharacters) {
charset = charset.replace(/[iIl10oO]/g, '');
}
let passwords = [];
for (let j = 0; j < count; j++) {
let password = '';
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * charset.length);
password += charset[randomIndex];
}
passwords.push(password);
}
document.getElementById('passwordDisplay').textContent = passwords.join('\\n');
// 只检测第一个密码的安全性
if (passwords.length > 0) {
const result = evaluatePassword(passwords[0]);
document.getElementById('score').innerText = \`安全得分: \${result.score} / 100\`;
document.getElementById('progress').style.width = \`\${result.score}%\`;
document.getElementById('progress').style.background = getColor(result.score);
document.getElementById('advice').innerHTML = result.advice;
}
}
function copyPassword() {
const passwordDisplay = document.getElementById('passwordDisplay');
const password = passwordDisplay.textContent;
const tempInput = document.createElement('textarea');
tempInput.value = password;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand('copy');
document.body.removeChild(tempInput);
alert('Password copied to clipboard!');
}
function generateUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
function generateUUIDs() {
const count = document.getElementById('passwordCount').value;
let uuids = [];
for (let i = 0; i < count; i++) {
uuids.push(generateUUID());
}
document.getElementById('passwordDisplay').textContent = uuids.join('\\n');
// 生成UUID时清除安全性检测结果
document.getElementById('score').innerText = '安全得分: 0 / 100';
document.getElementById('progress').style.width = '0%';
document.getElementById('advice').innerHTML = '';
}
function evaluatePassword(password) {
let score = 0;
let advice = '';
const length = password.length;
let hasLower = /[a-z]/.test(password);
let hasUpper = /[A-Z]/.test(password);
let hasDigit = /\\d/.test(password);
let hasSpecial = /[^a-zA-Z0-9]/.test(password);
let typeCount = 0;
if (hasLower) score += 5, typeCount++;
if (hasDigit) score += 5, typeCount++;
if (hasUpper) score += 10, typeCount++;
if (hasSpecial) score += 20, typeCount++;
// 字符重复限制处理
let repeatCount = 1;
let lastChar = '';
let bonusLength = 0;
for (let i = 0; i < password.length; i++) {
const char = password[i];
if (char === lastChar) {
repeatCount++;
} else {
repeatCount = 1;
lastChar = char;
}
if (i >= 6) { // 第7个字符起计入加分
if (repeatCount <= 3) {
bonusLength += 1;
}
}
}
let lengthBonus = Math.min(bonusLength * 4, 60);
score += lengthBonus;
const includedTypes = [];
if (hasDigit) includedTypes.push('数字');
if (hasLower) includedTypes.push('小写字母');
if (hasUpper) includedTypes.push('大写字母');
if (hasSpecial) includedTypes.push('特殊字符');
advice += \`包含:\${includedTypes.join('、')},有 \${length} 位。<br><br>\`;
// 提示建议
if (typeCount < 2) {
advice += "建议至少包含两种字符类型(如字母+数字)。<br><br>";
}
if (length < 8) {
advice += "密码长度建议至少为 8 位。<br><br>";
}
if (score < 20) {
advice += "️⚠️特弱,必须提升安全性,建议至少使用大小写字母、数字和特殊字符。<br><br>";
} else if (score < 40) {
advice += "⚠️弱,必须加强,可考虑增加长度或多样性。<br><br>";
} else if (score < 60) {
advice += "🛡️一般,必须进一步加强。<br><br>";
} else if (score < 80) {
advice += "️🛡️勉强可以,进一步加强。<br><br>";
} else if (score < 90) {
advice += "🔒安全!可进一步加强。<br><br>";
} else {
advice += "🔒非常安全!请定期更换。<br><br>";
}
// 估算破解时间
const timeEstimate = estimateCrackTime(password, typeCount);
advice += \`估计暴力破解时间:<strong>\${timeEstimate}</strong>\`;
return { score: Math.min(score, 100), advice };
}
function getColor(score) {
if (score < 20) return '#e74c3c'; // red
if (score < 40) return '#ff9900'; // #ff9900
if (score < 60) return '#66CDAA'; // #66CDAA
if (score < 80) return '#7CCD7C'; // #7CCD7C
if (score < 90) return '#27ae60'; // #27ae60
return 'green'; // green
}
function estimateCrackTime(password, typeCount) {
let charsetSize = 0;
if (/[a-z]/.test(password)) charsetSize += 26;
if (/[A-Z]/.test(password)) charsetSize += 26;
if (/\\d/.test(password)) charsetSize += 10;
if (/[^a-zA-Z0-9]/.test(password)) charsetSize += 32;
const combinations = BigInt(charsetSize) ** BigInt(password.length);
const guessesPerSecond = 1_000_000_00n; // 1 亿次/秒
const averageGuesses = combinations / 2n;
const seconds = averageGuesses / guessesPerSecond;
return formatTime(seconds);
}
function formatTime(seconds) {
const s = Number(seconds);
if (s < 60) return \`\${Math.round(s)} 秒\`;
if (s < 3600) return \`\${Math.round(s / 60)} 分钟\`;
if (s < 86400) return \`\${Math.round(s / 3600)} 小时\`;
if (s < 31536000) return \`\${Math.round(s / 86400)} 天\`;
const years = s / 31536000;
if (years < 10000) return \`\${Math.round(years)} 年\`;
if (years < 100000000) return \`\${(years / 10000).toFixed(1)} 万年\`;
if (years < 10000000000) return \`\${(years / 100000000).toFixed(1)} 亿年\`;
if (years < 1000000000000) return \`\${(years / 10000000000).toFixed(1)} 百亿年\`;
if (years < 1000000000000) return \`\${(years / 100000000000).toFixed(1)} 千亿年\`;
if (years < 1000000000000) return \`\${(years / 1000000000000).toFixed(1)} 万亿年\`;
return \`超过 \${Math.round(years / 10000000000000)} 兆亿年\`;
}
</script>
<div class="sites">
<!-- body 页脚 -->
<div class="footer">
©ws01 云DL备20241111-02号<br />
<!-- 开站时间开始 -->
<span id="timeDate">载入天数...</span>
<script language="javascript">
var now = new Date();
function createtime(){
var grt= new Date("11/15/2025 00:00:00");/*---这里是网站的启用时间--*/
now.setTime(now.getTime()+250);
days = (now - grt ) / 1000 / 60 / 60 / 24;
dnum = Math.floor(days);
document.getElementById("timeDate").innerHTML = "稳定运行"+dnum+"天";
}
setInterval("createtime()",250);
</script>
<span <p> | 本页总访问量 <span id="busuanzi_site_pv"></span> 次 </p></span>
<script defer src="https://bsz.211119.xyz/js"></script>
<!-- 开站时间结束 -->
</body>
</html>`;
return new Response(html, {
headers: { 'content-type': 'text/html;charset=UTF-8' },
});
}