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\~ 谢谢各位了!
请问这个java里的函数如何用php语言表达出来?
php自带