From 9bf72b278110fecea0fc1052fc2b0ded188d192a Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Tue, 16 Mar 2021 19:30:54 -0400 Subject: [PATCH] make signing simpler shall we --- app/src/main/java/awais/instagrabber/utils/Utils.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/utils/Utils.java b/app/src/main/java/awais/instagrabber/utils/Utils.java index b69c01d1..02103468 100644 --- a/app/src/main/java/awais/instagrabber/utils/Utils.java +++ b/app/src/main/java/awais/instagrabber/utils/Utils.java @@ -93,20 +93,16 @@ public final class Utils { } public static Map sign(final Map form) { - final String signed = sign(new JSONObject(form).toString()); + final String signed = sign(Constants.SIGNATURE_KEY, new JSONObject(form).toString()); if (signed == null) { return null; } final Map map = new HashMap<>(); map.put("ig_sig_key_version", Constants.SIGNATURE_VERSION); - map.put("signed_body", signed.split("&signed_body=")[1]); + map.put("signed_body", signed); return map; } - public static String sign(final String message) { - return sign(Constants.SIGNATURE_KEY, message); - } - public static String sign(final String key, final String message) { try { final Mac hasher = Mac.getInstance("HmacSHA256"); @@ -118,7 +114,7 @@ public final class Utils { if (hex.length() == 1) hexString.append('0'); hexString.append(hex); } - return "ig_sig_key_version=" + Constants.SIGNATURE_VERSION + "&signed_body=" + hexString.toString() + "." + message; + return hexString.toString() + "." + message; } catch (Exception e) { Log.e(TAG, "Error signing", e); return null;