Skip to content

Instantly share code, notes, and snippets.

@deepak140596
Last active October 30, 2019 15:52
Show Gist options
  • Save deepak140596/e7bceea401bea9f9a0bce683efaa4808 to your computer and use it in GitHub Desktop.
Save deepak140596/e7bceea401bea9f9a0bce683efaa4808 to your computer and use it in GitHub Desktop.
String hashSequence = merchantKey + "|" + txnId + "|" + amount + "|" + productInfo + "|" + firstName + "|" + email + "|" +
udf1 + "|" + udf2 + "|" + udf3 + "|" + udf4 + "|" + udf5 + "|" + "|" + "|" + "|" + "|" + "|" + salt;
public static String hashCal(String type, String hashString) {
StringBuilder hash = new StringBuilder();
MessageDigest messageDigest = null;
try {
messageDigest = MessageDigest.getInstance(type);
messageDigest.update(hashString.getBytes());
byte[] mdbytes = messageDigest.digest();
for (byte hashByte : mdbytes) {
hash.append(Integer.toString((hashByte & 0xff) + 0x100, 16).substring(1));
}
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return hash.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment