mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 14:47:29 +00:00
make signing simpler shall we
This commit is contained in:
parent
d65fbd4193
commit
9bf72b2781
@ -93,20 +93,16 @@ public final class Utils {
|
||||
}
|
||||
|
||||
public static Map<String, String> sign(final Map<String, Object> 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<String, String> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user