Skip to content

Commit

Permalink
Update check.html
Browse files Browse the repository at this point in the history
  • Loading branch information
OrO-c authored Sep 1, 2024
1 parent a43d2f0 commit 6b3b253
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions tool/cookietest/check.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
font-size: 16px;
}
</style>
<!-- 引入 js-md5 库 -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-md5/0.7.3/md5.min.js"></script>
<!-- 引入 MD5 库 -->
<script src="https://raw.githubusercontent.com/nightgpt/nightgpt.github.io/main/tool/cookietest/md5.js"></script>
</head>
<body>
<div class="container">
Expand All @@ -59,12 +59,12 @@ <h2>请输入密码</h2>
</div>

<script>
// 设置 Cookie 的函数
// 设置Cookie的函数
function setCookie(name, value, maxAge) {
document.cookie = `${name}=${value}; max-age=${maxAge}; path=/`;
}

// 检查是否存在名为 ZhaoxiZf 的 Cookie
// 检查是否存在名为 ZhaoxiZf 的Cookie
function checkZhaoxiZfCookie() {
return document.cookie.split('; ').some(cookie => cookie.startsWith('ZhaoxiZf='));
}
Expand All @@ -73,30 +73,30 @@ <h2>请输入密码</h2>
function validatePassword() {
const password = document.getElementById('password').value;
const messageElement = document.getElementById('message');

// 计算密码的 MD5 摘要
const md5Password = md5(password);

// MD5 摘要的存储值
const md5True = md5("d6c6d8f004b7529ae4d22bda37083172");
const md5Zifen = md5("zifen");
// 密码的 MD5 摘要(假设为以下值)
const validMd5ForTrue = '098f6bcd4621d373cade4e832627b4f6'; // 'true' 的 MD5 摘要
const validMd5ForZifen = '5f4dcc3b5aa765d61d8327deb882cf99'; // 'zifen' 的 MD5 摘要

// 计算输入密码的 MD5 摘要
const inputMd5 = md5(password);

if (checkZhaoxiZfCookie()) {
// 如果存在 ZhaoxiZf Cookie,无论输入什么密码都显示错误
messageElement.textContent = "密码错误!";
messageElement.style.color = "red";
} else {
if (md5Password === md5True) {
// 输入 true,验证成功,设置 ZhaoiiCookq Cookie,有效期 60 秒,跳转到 privacy.html
if (inputMd5 === validMd5ForTrue) {
// 输入true,验证成功,设置ZhaoiiCookq Cookie,有效期60秒,跳转到privacy.html
setCookie('ZhaoiiCookq', 'true', 60);
messageElement.textContent = "密码验证成功!";
messageElement.style.color = "green";
setTimeout(() => {
window.location.href = "privacy.html";
}, 1000);
} else if (md5Password === md5Zifen) {
// 输入 zifen,验证成功,设置 ZhaoxiZf Cookie,有效期为永久
setCookie('ZhaoxiZf', 'true', 60*60*24*365*100); // 设置 100 年,等同于永久
} else if (inputMd5 === validMd5ForZifen) {
// 输入zifen,验证成功,设置ZhaoxiZf Cookie,有效期为永久
setCookie('ZhaoxiZf', 'true', 60*60*24*365*100); // 设置100年,等同于永久
messageElement.textContent = "密码验证成功!";
messageElement.style.color = "green";
} else {
Expand Down

0 comments on commit 6b3b253

Please sign in to comment.