From 8465dcfe7c88a63fcd94a30738b7bc588d5e6d6a Mon Sep 17 00:00:00 2001 From: RohitKushvaha01 Date: Thu, 12 Mar 2026 18:31:34 +0530 Subject: [PATCH 1/2] feat: move checksumText to native --- src/lib/installState.js | 11 ++++-- .../android/com/foxdebug/system/System.java | 34 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/lib/installState.js b/src/lib/installState.js index 0c7de5882..a1f41bff0 100644 --- a/src/lib/installState.js +++ b/src/lib/installState.js @@ -159,6 +159,13 @@ async function checksum(data) { * @returns */ async function checksumText(text) { - const textUint8 = new TextEncoder().encode(text); - return await checksum(textUint8); + return new Promise((resolve, reject) => { + cordova.exec( + (hash) => resolve(hash), + (error) => reject(error), + "System", + "checksumText", + [text], + ); + }); } diff --git a/src/plugins/system/android/com/foxdebug/system/System.java b/src/plugins/system/android/com/foxdebug/system/System.java index 69edbffb8..45b92db8f 100644 --- a/src/plugins/system/android/com/foxdebug/system/System.java +++ b/src/plugins/system/android/com/foxdebug/system/System.java @@ -107,6 +107,13 @@ import android.graphics.ImageDecoder; +import org.apache.cordova.*; +import org.json.JSONArray; +import org.json.JSONException; + +import java.security.MessageDigest; + + public class System extends CordovaPlugin { private static final String TAG = "SystemPlugin"; @@ -560,6 +567,33 @@ public void run() { break; case "compare-texts": compareTexts(arg1, arg2, callbackContext); + break; + case "checksumText": + + cordova.getThreadPool().execute(() -> { + try { + + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + + byte[] hash = digest.digest(args.getString(0).getBytes("UTF-8")); + + StringBuilder hexString = new StringBuilder(); + + for (byte b : hash) { + String hex = Integer.toHexString(0xff & b); + + if (hex.length() == 1) hexString.append('0'); + + hexString.append(hex); + } + + + callbackContext.success(hexString.toString()); + } catch (Exception e) { + callbackContext.error(e.getMessage()); + } + }); + break; default: break; From 1bdd58cf43963146f5491ac15965983dddcd3dbc Mon Sep 17 00:00:00 2001 From: Rohit Kushvaha Date: Thu, 12 Mar 2026 18:35:30 +0530 Subject: [PATCH 2/2] Update src/plugins/system/android/com/foxdebug/system/System.java Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- src/plugins/system/android/com/foxdebug/system/System.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/plugins/system/android/com/foxdebug/system/System.java b/src/plugins/system/android/com/foxdebug/system/System.java index 45b92db8f..1adf80bb4 100644 --- a/src/plugins/system/android/com/foxdebug/system/System.java +++ b/src/plugins/system/android/com/foxdebug/system/System.java @@ -107,10 +107,7 @@ import android.graphics.ImageDecoder; -import org.apache.cordova.*; -import org.json.JSONArray; -import org.json.JSONException; - +import java.security.MessageDigest; import java.security.MessageDigest;