Skip to content

Commit

Permalink
fix: remove md5 usage
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-fiedler committed Jun 30, 2023
1 parent d950578 commit abfa8e1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 744 deletions.
21 changes: 0 additions & 21 deletions src/main/java/com/amplitude/api/AmplitudeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.amplitude.analytics.connector.Identity;
import com.amplitude.analytics.connector.util.JSONUtil;
import com.amplitude.eventexplorer.EventExplorer;
import com.amplitude.security.MD5;
import com.amplitude.util.DoubleCheck;
import com.amplitude.util.Provider;

Expand All @@ -22,8 +21,6 @@
import org.json.JSONObject;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
Expand Down Expand Up @@ -2268,29 +2265,11 @@ protected void makeEventUploadPostRequest(Call.Factory client, String events, fi
String apiVersionString = "" + Constants.API_VERSION;
String timestampString = "" + getCurrentTimeMillis();

String checksumString = "";
try {
String preimage = apiVersionString + apiKey + events + timestampString;

// MessageDigest.getInstance(String) is not threadsafe on Android.
// See https://code.google.com/p/android/issues/detail?id=37937
// Use MD5 implementation from http://org.rodage.com/pub/java/security/MD5.java
// This implementation does not throw NoSuchAlgorithm exceptions.
MessageDigest messageDigest = new MD5();
checksumString = bytesToHexString(messageDigest.digest(preimage.getBytes("UTF-8")));
} catch (UnsupportedEncodingException e) {
// According to
// http://stackoverflow.com/questions/5049524/is-java-utf-8-charset-exception-possible,
// this will never be thrown
logger.e(TAG, e.toString());
}

FormBody body = new FormBody.Builder()
.add("v", apiVersionString)
.add("client", apiKey)
.add("e", events)
.add("upload_time", timestampString)
.add("checksum", checksumString)
.build();

Request request;
Expand Down
Loading

0 comments on commit abfa8e1

Please sign in to comment.