一分钟搭建影视站,支持Docker等部署方式
引入js-sha256库以支持HTTP环境下的SHA-256哈希计算,并增强密码验证功能的兼容性
developerbd8fb7f101a1
diff --git a/index.html b/index.htmlindex 5add310..27aa7aa 100644--- a/index.html+++ b/index.html@@ -325,6 +325,8 @@}</script>+ <!-- 引入纯 JS sha256(HTTP 下依然可用) -->+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/build/sha256.min.js"></script><script src="js/config.js"></script><script src="js/ui.js"></script><script src="js/api.js"></script>diff --git a/js/password.js b/js/password.jsindex 1da2ba5..afb2699 100644--- a/js/password.js+++ b/js/password.js@@ -62,10 +62,17 @@ async function verifyPassword(password) {// SHA-256实现,可用Web Crypto APIasync function sha256(message) {- const msgBuffer = new TextEncoder().encode(message);- const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);- const hashArray = Array.from(new Uint8Array(hashBuffer));- return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');+ if (window.crypto && crypto.subtle && crypto.subtle.digest) {+ const msgBuffer = new TextEncoder().encode(message);+ const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);+ const hashArray = Array.from(new Uint8Array(hashBuffer));+ return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');+ }+ // HTTP 环境下使用 js-sha256 库兜底+ if (typeof sha256 === 'function') {+ return window.sha256(message);+ }+ throw new Error('No SHA-256 implementation available.');}/**