文章加密

Posted by 晴天,微冷 on February 10, 2026

代码

加密网址https://app.2091k.cn/jiami

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!-- 哈希版解密模块(源码无明文密码) -->
<div id="hash-crypto-container" style="margin: 20px 0; font-family: 'Microsoft Yahei', Roboto, sans-serif;">
  <div id="hash-prompt" style="padding: 15px; background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px; margin-bottom: 10px;">
    <p style="margin: 0 0 10px 0; color: #333; font-size: 14px;">请输入密码查看代码:</p>
    <input 
      type="password" 
      id="hash-pwd" 
      placeholder="输入查看密码"
      style="padding: 8px 12px; width: 250px; border: 1px solid #ddd; border-radius: 4px; margin-right: 8px; font-size: 14px;"
      onkeydown="if(event.key === 'Enter') decryptByHash()"
    >
    <button 
      onclick="decryptByHash()"
      style="padding: 8px 16px; background: #286090; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;"
    >
      解密查看
    </button>
  </div>
  
  <div id="hash-result" style="display: none;">
    <pre style="margin: 0; padding: 16px; background: #f5f5f5; border-radius: 6px; overflow-x: auto;">
      <code class="language-vb" id="hash-decrypted-text" style="color: #333; font-family: Consolas, monospace; font-size: 14px; line-height: 1.5;"></code>
    </pre>
  </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/crypto-js.min.js"></script>
<script>
// ===================== 配置(仅存哈希,无明文密码) =====================
const PWD_HASH = "哈希值"; // 如:f8095880e8937d7c968f5b81e0903be9f30c266f2f6f28b8b8b8b8b8b8b8b8b8";
const AES_KEY = CryptoJS.enc.Utf8.parse("1234567890123456");
const AES_IV = CryptoJS.enc.Utf8.parse("abcdefghijklmnop");
const ENCRYPTED_TEXT = "密文";

// ===================== 哈希验证+解密 =====================
function decryptByHash() {
  const pwdInput = document.getElementById("hash-pwd");
  const inputPwd = pwdInput.value.trim();
  
  if (inputPwd === "") {
    alert("请输入密码!");
    pwdInput.focus();
    return;
  }

  // 关键:生成输入密码的哈希,和源码中的哈希对比(无明文密码)
  const inputHash = CryptoJS.SHA256(inputPwd).toString();
  if (inputHash !== PWD_HASH) {
    alert("❌ 密码错误!");
    pwdInput.value = "";
    pwdInput.focus();
    return;
  }

  try {
    // 解密逻辑(和之前一致)
    const cipherParams = CryptoJS.lib.CipherParams.create({
      ciphertext: CryptoJS.enc.Base64.parse(ENCRYPTED_TEXT)
    });
    const decryptedData = CryptoJS.AES.decrypt(cipherParams, AES_KEY, {
      iv: AES_IV,
      mode: CryptoJS.mode.CBC,
      padding: CryptoJS.pad.Pkcs7
    });
    const originalText = CryptoJS.enc.Utf8.stringify(decryptedData);

    document.getElementById("hash-decrypted-text").textContent = originalText;
    document.getElementById("hash-result").style.display = "block";
    document.getElementById("hash-prompt").style.display = "none";
    alert("✅ 密码正确!");
    
  } catch (error) {
    alert("❌ 解密失败:" + error.message);
    pwdInput.value = "";
    pwdInput.focus();
  }
}

window.onload = function() {
  document.getElementById("hash-pwd").focus();
};
</script>