Skip to content

Commit

Permalink
Address review comments and change algorithm logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Mansi-mParticle committed Nov 26, 2024
1 parent 2e832ca commit 9d432bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ public String convertString(){
}

public String objectToHash() {
String input =this.toString();
String input = this.toString();
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] hashBytes = md.digest(input.getBytes());
StringBuilder hexString = new StringBuilder();
for (byte b : hashBytes) {
Expand All @@ -253,8 +253,9 @@ public String objectToHash() {
hexString.append(hex);
}
return hexString.toString().substring(0, 16); // Shorten to first 16 characters
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (Exception e) {
Logger.error("Exception while initializing SHA-1 on device:" + e);
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ private void catchRequest(IdentityApiRequest request, IdentityHttpResponse ident
identityCacheTime = System.currentTimeMillis();
mConfigManager.saveIdentityCacheTime(identityCacheTime);
}
String key = request.objectToHash() + callType;
String key = (request.objectToHash() == null) ? null : request.objectToHash() + callType;


identityCacheArray.put(key, identityHttpResponse);
mConfigManager.saveIdentityCache(key, identityHttpResponse);
Expand Down

0 comments on commit 9d432bd

Please sign in to comment.