security: SHA256校验通过Android Bridge(Java侧计算)

- Bridge.sha256() 用 MessageDigest 计算
- JS下载后 Android.sha256(t) 比对 version.txt 哈希
- version.txt 恢复三列: ver|url|sha256
- 避免 Web Crypto API 在 file:// 域不可用问题
This commit is contained in:
LukeMackin
2026-07-21 20:30:45 +08:00
parent 70c535d0c1
commit 67adde25a4
4 changed files with 7 additions and 1 deletions

View File

@@ -1 +1 @@
0.1.0-dav-android-6|https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota/h5/index-v6.html
0.1.0-dav-android-6|https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota/h5/index-v6.html|a53319e28c5b9ce5da6799d9b2fe547f4391386f23b68ac10814567edd445188

View File

@@ -48,6 +48,12 @@ class MainActivity : AppCompatActivity() {
ctx.cacheFile.delete()
Log.i(TAG, "Cache cleared")
}
@android.webkit.JavascriptInterface
fun sha256(input: String): String {
val md = java.security.MessageDigest.getInstance("SHA-256")
val digest = md.digest(input.toByteArray(Charsets.UTF_8))
return digest.joinToString("") { "%02x".format(it) }
}
}
companion object { private const val TAG = "GCA-H5" }