<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>一次性临时密码生成器</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
padding: 20px;
}
.container {
max-width: 600px;
margin: 0 auto;
background-color: white;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
h1 {
text-align: center;
color: #333;
margin-bottom: 30px;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: #555;
}
input {
width: 100%;
padding: 12px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 16px;
}
.checkbox-group {
display: flex;
align-items: center;
}
.checkbox-group input {
width: auto;
margin-right: 10px;
}
button {
width: 100%;
padding: 15px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
font-size: 18px;
font-weight: bold;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #45a049;
}
.result {
margin-top: 30px;
padding: 20px;
background-color: #f9f9f9;
border-radius: 4px;
border-left: 4px solid #4CAF50;
}
.result h2 {
color: #333;
margin-bottom: 15px;
}
.password {
font-size: 24px;
font-weight: bold;
color: #333;
margin: 10px 0;
padding: 10px;
background-color: #e8f5e9;
border-radius: 4px;
text-align: center;
}
.tips {
color: #666;
margin-top: 10px;
line-height: 1.5;
}
.copy-btn {
margin-top: 10px;
padding: 8px 16px;
background-color: #2196F3;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
}
.copy-btn:hover {
background-color: #0b7dda;
}
.error {
color: red;
margin-top: 5px;
font-size: 14px;
}
</style>
</head>
<body>
<div class="container">
<h1>一次性临时密码生成器</h1>
<form id="generatorForm">
<div class="form-group">
<label for="adminPasswd">管理员密码</label>
<input type="password" id="adminPasswd" value="115889198" placeholder="请输入管理员密码" required>
</div>
<div class="form-group checkbox-group">
<input type="checkbox" id="customTime">
<label for="customTime">自定义时间</label>
</div>
<div class="form-group" id="timeGroup" style="display: none;">
<label for="customDateTime">选择时间</label>
<input type="datetime-local" id="customDateTime">
</div>
<button type="submit">生成临时密码</button>
</form>
<div class="result" id="result" style="display: none;">
<h2>生成结果</h2>
<div class="password" id="tempPasswd"></div>
<div class="tips" id="tips"></div>
<button class="copy-btn" onclick="copyPassword()">复制密码</button>
</div>
</div>
<script>
// MD5 算法实现
function md5(r) {
function t(r, t) {
return (r << t) | (r >>> (32 – t));
}
function n(r, t) {
var n, e, o, u, a;
return (
(o = 2147483648 & r),
(u = 2147483648 & t),
(a = (1073741823 & r) + (1073741823 & t)),
(n = 1073741824 & r) & (e = 1073741824 & t)
? 2147483648 ^ a ^ o ^ u
: n | e
? 1073741824 & a
? 3221225472 ^ a ^ o ^ u
: 1073741824 ^ a ^ o ^ u
: a ^ o ^ u
);
}
function e(r, e, o, u, a, f, i) {
return (
(r = n(
r,
n(
n(
(function (r, t, n) {
return (r & t) | (~r & n);
})(e, o, u),
a
),
i
)
)),
n(t(r, f), e)
);
}
function o(r, e, o, u, a, f, i) {
return (
(r = n(
r,
n(
n(
(function (r, t, n) {
return (r & n) | (t & ~n);
})(e, o, u),
a
),
i
)
)),
n(t(r, f), e)
);
}
function u(r, e, o, u, a, f, i) {
return (
(r = n(
r,
n(
n(
(function (r, t, n) {
return r ^ t ^ n;
})(e, o, u),
a
),
i
)
)),
n(t(r, f), e)
);
}
function a(r, e, o, u, a, f, i) {
return (
(r = n(
r,
n(
n(
(function (r, t, n) {
return t ^ (r | ~n);
})(e, o, u),
a
),
i
)
)),
n(t(r, f), e)
);
}
function f(r) {
var t, n = "", e = "";
for (t = 0; t <= 3; t++)
n += (e = "0" + ((r >>> (8 * t)) & 255).toString(16)).substr(
e.length – 2,
2
);
return n;
}
var i, g, s, c, v, l, h, w, M, d = Array();
for (
d = (function (r) {
for (
var t, n = r.length, e = n + 8, o = 16 * ((e – (e % 64)) / 64 + 1), u = Array(o – 1), a = 0, f = 0;
f < n;
)
(a = (f % 4) * 8),
(u[(t = (f – (f % 4)) / 4)] = u[t] | (r.charCodeAt(f) << a)),
f++;
return (
(a = (f % 4) * 8),
(u[(t = (f – (f % 4)) / 4)] = u[t] | (128 << a)),
(u[o – 2] = n << 3),
(u[o – 1] = n >>> 29),
u
);
})(r),
l = 1732584193,
h = 4023233417,
w = 2562383102,
M = 271733878,
i = 0;
i < d.length;
i += 16
)
(g = l),
(s = h),
(c = w),
(v = M),
(l = e(l, h, w, M, d[i + 0], 7, 3614090360)),
(M = e(M, l, h, w, d[i + 1], 12, 3905402710)),
(w = e(w, M, l, h, d[i + 2], 17, 606105819)),
(h = e(h, w, M, l, d[i + 3], 22, 3250441966)),
(l = e(l, h, w, M, d[i + 4], 7, 4118548399)),
(M = e(M, l, h, w, d[i + 5], 12, 1200080426)),
(w = e(w, M, l, h, d[i + 6], 17, 2821735955)),
(h = e(h, w, M, l, d[i + 7], 22, 4249261313)),
(l = e(l, h, w, M, d[i + 8], 7, 1770035416)),
(M = e(M, l, h, w, d[i + 9], 12, 2336552879)),
(w = e(w, M, l, h, d[i + 10], 17, 4294925233)),
(h = e(h, w, M, l, d[i + 11], 22, 2304563134)),
(l = e(l, h, w, M, d[i + 12], 7, 1804603682)),
(M = e(M, l, h, w, d[i + 13], 12, 4254626195)),
(w = e(w, M, l, h, d[i + 14], 17, 2792965006)),
(l = o(
l,
(h = e(h, w, M, l, d[i + 15], 22, 1236535329)),
w,
M,
d[i + 1],
5,
4129170786
)),
(M = o(M, l, h, w, d[i + 6], 9, 3225465664)),
(w = o(w, M, l, h, d[i + 11], 14, 643717713)),
(h = o(h, w, M, l, d[i + 0], 20, 3921069994)),
(l = o(l, h, w, M, d[i + 5], 5, 3593408605)),
(M = o(M, l, h, w, d[i + 10], 9, 38016083)),
(w = o(w, M, l, h, d[i + 15], 14, 3634488961)),
(h = o(h, w, M, l, d[i + 4], 20, 3889429448)),
(l = o(l, h, w, M, d[i + 9], 5, 568446438)),
(M = o(M, l, h, w, d[i + 14], 9, 3275163606)),
(w = o(w, M, l, h, d[i + 3], 14, 4107603335)),
(h = o(h, w, M, l, d[i + 8], 20, 1163531501)),
(l = o(l, h, w, M, d[i + 13], 5, 2850285829)),
(M = o(M, l, h, w, d[i + 2], 9, 4243563512)),
(w = o(w, M, l, h, d[i + 7], 14, 1735328473)),
(l = u(
l,
(h = o(h, w, M, l, d[i + 12], 20, 2368359562)),
w,
M,
d[i + 5],
4,
4294588738
)),
(M = u(M, l, h, w, d[i + 8], 11, 2272392833)),
(w = u(w, M, l, h, d[i + 11], 16, 1839030562)),
(h = u(h, w, M, l, d[i + 14], 23, 4259657740)),
(l = u(l, h, w, M, d[i + 1], 4, 2763975236)),
(M = u(M, l, h, w, d[i + 4], 11, 1272893353)),
(w = u(w, M, l, h, d[i + 7], 16, 4139469664)),
(h = u(h, w, M, l, d[i + 10], 23, 3200236656)),
(l = u(l, h, w, M, d[i + 13], 4, 681279174)),
(M = u(M, l, h, w, d[i + 0], 11, 3936430074)),
(w = u(w, M, l, h, d[i + 3], 16, 3572445317)),
(h = u(h, w, M, l, d[i + 6], 23, 76029189)),
(l = u(l, h, w, M, d[i + 9], 4, 3654602809)),
(M = u(M, l, h, w, d[i + 12], 11, 3873151461)),
(w = u(w, M, l, h, d[i + 15], 16, 530742520)),
(l = a(
l,
(h = u(h, w, M, l, d[i + 2], 23, 3299628645)),
w,
M,
d[i + 0],
6,
4096336452
)),
(M = a(M, l, h, w, d[i + 7], 10, 1126891415)),
(w = a(w, M, l, h, d[i + 14], 15, 2878612391)),
(h = a(h, w, M, l, d[i + 5], 21, 4237533241)),
(l = a(l, h, w, M, d[i + 12], 6, 1700485571)),
(M = a(M, l, h, w, d[i + 3], 10, 2399980690)),
(w = a(w, M, l, h, d[i + 10], 15, 4293915773)),
(h = a(h, w, M, l, d[i + 1], 21, 2240044497)),
(l = a(l, h, w, M, d[i + 8], 6, 1873313359)),
(M = a(M, l, h, w, d[i + 15], 10, 4264355552)),
(w = a(w, M, l, h, d[i + 6], 15, 2734768916)),
(h = a(h, w, M, l, d[i + 13], 21, 1309151649)),
(l = a(l, h, w, M, d[i + 4], 6, 4149444226)),
(M = a(M, l, h, w, d[i + 11], 10, 3174756917)),
(w = a(w, M, l, h, d[i + 2], 15, 718787259)),
(h = a(h, w, M, l, d[i + 9], 21, 3951481745)),
(l = n(l, g)),
(h = n(h, s)),
(w = n(w, c)),
(M = n(M, v));
return (f(l) + f(h) + f(w) + f(M)).toLowerCase();
}
// 辅助函数
function hexToBytes(hex) {
var bytes = [];
if (hex.length % 2 != 0) return null;
var len = hex.length / 2;
for (var i = 0; i < len; i++) {
var hexByte = hex.substr(i * 2, 2);
bytes.push(parseInt(hexByte, 16));
}
return bytes;
}
function bytesToNumber(bytes) {
var number = 0;
for (var i = 0; i < bytes.length; i++) {
number += Math.pow(256, i) * bytes[i];
}
return number;
}
function transformBits(r, t) {
var e = [
[8, 9, 10, 11, 0, 1, 2, 3, 4, 14, 5, 13, 6, 12, 7],
[4, 5, 6, 7, 8, 9, 12, 0, 13, 1, 14, 2, 10, 3, 11],
[2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 0, 8, 1, 9],
[12, 1, 7, 2, 8, 14, 3, 9, 4, 10, 13, 5, 11, 0, 6],
];
var o = 0;
for (var n = 0; n < 15; n++) {
if (0 != (r & (1 << e[t][n]))) {
o |= 1 << n;
}
}
return (o &= 32767);
}
// 生成临时密码
function generatePasswd(adminPasswd, timestamp) {
var result = "";
for (var f = 0; f < 2; f++) {
var i = timestamp;
i -= 1483200000;
i = Math.floor(i / 900);
i = Math.floor(i % 16384);
if (1 == f) i |= 16384;
var s = adminPasswd;
for (var g = s.length; g < 16; g++) {
s += String.fromCharCode(0);
}
s += String.fromCharCode((i >> 8) & 255);
s += String.fromCharCode(255 & i);
var md5Hash = md5(s);
var c = hexToBytes(md5Hash);
var v = 0;
for (var l = 0; l < 16; l += 2) {
v += c[l];
}
var h = transformBits(i, 3 & (v &= 31));
var w = new Array(3);
w[0] = (v >> 1) & 15;
w[1] = ((v << 7) & 128) | ((h >> 8) & 127);
w[2] = 255 & h;
var M = new Array(3);
M[0] = w[2];
M[1] = w[1];
M[2] = w[0];
var p = bytesToNumber(M);
if ((p &= 16777215) > 1000000) {
p %= 1000000;
}
var C = p.toString(10);
if (C.length < 6) {
for (var d = 0; d < 6 – C.length; d++) {
C = "0" + C;
}
} else if (C.length > 6) {
C = C.substr(C.length – 6, 6);
}
if (f == 0) {
result = C + "/";
} else {
result += C;
}
}
return result;
}
// 获取当前时间戳(秒)
function getNowTimeSeconds() {
var r = new Date().valueOf();
return Math.floor(r / 1000);
}
// 格式化时间范围
function getNowFormatStartMinutes(date) {
var t = date;
var n = t.getMonth() + 1;
var e = t.getDate();
if (n >= 1 && n <= 9) n = "0" + n;
if (e >= 0 && e <= 9) e = "0" + e;
var o = t.getMinutes();
o = o < 15 ? "00" : o >= 15 && o < 30 ? "15" : o >= 30 && o < 45 ? "30" : "45";
return t.getFullYear() + "-" + n + "-" + e + " " + t.getHours() + ":" + o;
}
function getNowFormatEndMinutes(date) {
var t = date;
var n = t.getMonth() + 1;
var e = t.getDate();
if (n >= 1 && n <= 9) n = "0" + n;
if (e >= 0 && e <= 9) e = "0" + e;
var o = t.getMinutes();
o = o < 15 ? "14" : o >= 15 && o < 30 ? "29" : o >= 30 && o < 45 ? "44" : "59";
return t.getFullYear() + "-" + n + "-" + e + " " + t.getHours() + ":" + o;
}
// 事件监听
document.getElementById('customTime').addEventListener('change', function() {
var timeGroup = document.getElementById('timeGroup');
if (this.checked) {
timeGroup.style.display = 'block';
} else {
timeGroup.style.display = 'none';
}
});
document.getElementById('generatorForm').addEventListener('submit', function(e) {
e.preventDefault();
var adminPasswd = document.getElementById('adminPasswd').value;
if (!adminPasswd) {
alert('请输入管理员密码');
return;
}
var timestamp;
var customTime = document.getElementById('customTime').checked;
if (customTime) {
var customDateTime = document.getElementById('customDateTime').value;
if (!customDateTime) {
alert('请选择时间');
return;
}
timestamp = Math.floor(new Date(customDateTime).getTime() / 1000);
} else {
timestamp = getNowTimeSeconds();
}
console.log('管理员密码:', adminPasswd);
console.log('时间戳:', timestamp);
// 生成密码
var passwdResult = generatePasswd(adminPasswd, timestamp);
//var passwords = passwdResult.split('/');
var passwords = passwdResult;
// 显示结果
document.getElementById('tempPasswd').textContent = passwords;
var startDate = new Date(timestamp * 1000);
var endDate = new Date((timestamp + 900) * 1000);
var tips = '密码有效时间\\n[' + getNowFormatStartMinutes(startDate) + ' – ' + getNowFormatEndMinutes(startDate) + ']\\n过期请重新生成';
document.getElementById('tips').textContent = tips;
document.getElementById('result').style.display = 'block';
});
// 复制密码
function copyPassword() {
var passwd = document.getElementById('tempPasswd').textContent;
navigator.clipboard.writeText(passwd).then(function() {
alert('密码已复制到剪贴板');
}, function() {
alert('复制失败,请手动复制');
});
}
// 初始化
window.onload = function() {
// 设置当前时间
var now = new Date();
var year = now.getFullYear();
var month = String(now.getMonth() + 1).padStart(2, '0');
var day = String(now.getDate()).padStart(2, '0');
var hours = String(now.getHours()).padStart(2, '0');
var minutes = String(now.getMinutes()).padStart(2, '0');
var formattedDate = year + '-' + month + '-' + day + 'T' + hours + ':' + minutes;
document.getElementById('customDateTime').value = formattedDate;
};
</script>
</body>
</html>
![【题解】[COCI 2025/2026 #6] 滑雪 / Skijanje(李超树 0 基础友好喵)-171主机测评](https://www.171host.com/wp-content/uploads/2026/08/20260826083930-6a8ea642697bc-220x25.png)