|
8精币
一个app的加密方法,md5_new(str),加密后的长度为22位,求解下用易语言怎么写?
public static String MD5_New(String str) {
String md5Str1 = null;
if (!(str == null || str.length() == 0)) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
try {
md.update(str.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
byte[] b = md.digest();
StringBuffer buf = new StringBuffer(ChooseTime.TIME_STYLE);
for (int i : b) {
int i2;
if (i2 < 0) {
i2 += LoginEvent.UPDATA_PRODUCT_FAILED;
}
if (i2 < 16) {
buf.append("0");
}
buf.append(Integer.toHexString(i2));
}
try {
md5Str1 = Base64.encodeBytes(buf.toString().getBytes("UTF-8"));
} catch (UnsupportedEncodingException e2) {
e2.printStackTrace();
}
} catch (NoSuchAlgorithmException e3) {
e3.printStackTrace();
}
}
return md5Str1;
}
|
|