public static String MD5(String text, String charset) {
char[] DIGITS = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
MessageDigest msgDigest = null;
try {
msgDigest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException var6) {
throw new IllegalStateException("System doesn't support MD5 algorithm.");
}
try {
msgDigest.update(text.getBytes(charset));
} catch (UnsupportedEncodingException var5) {
throw new IllegalStateException("System doesn't support your EncodingException.");
}
byte[] bytes = msgDigest.digest();
int l = bytes.length;
char[] out = new char[l << 1];
int i = 0;
for(int j = 0; i < l; ++i) {
out[j++] = DIGITS[(240 & bytes[i]) >>> 4];
out[j++] = DIGITS[15 & bytes[i]];
}
String md5Str = new String(out);
return md5Str;
}
請問以上代碼如何轉為php的函式,新手看不太懂java~ 謝謝各位了!
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/268597.html
標籤:Web 開發
上一篇:求微信小程式前端加后端原始碼或者教學視頻!!!越詳細越好!!!
下一篇:java 小白
