-
-
Save arran4/5791291 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Call with: | |
String date = getDate(); | |
String md5 = getMD5("passwprd", date); | |
checkauth(date, md5, email); | |
Code: | |
public String getMD5(String mobilePassword, String date) throws NoSuchAlgorithmException { | |
MessageDigest md = MessageDigest.getInstance("MD5"); | |
String fullHash = mobilePassword + date; | |
md.update(fullHash.getBytes()); | |
byte byteData[] = md.digest(); | |
StringBuffer hexString = new StringBuffer(); | |
for (int i=0;i<byteData.length;i++) { | |
String hex=Integer.toHexString(0xff & byteData[i]); | |
if(hex.length()==1) hexString.append('0'); | |
hexString.append(hex); | |
} | |
return hexString.toString(); | |
} | |
private String getDate(){ | |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); | |
format.setTimeZone(TimeZone.getTimeZone("UTC")); | |
Date date = new Date(); | |
return format.format(date); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment