MD5加密:
/** * MD5加密验证 * @param time 时间戳字符串 * @param domainName 请求数据表明 * @return */ def md5Key(String time,String domainName){ def token = "id=" + StaticUtils.IMOCCA_X_LC_ID + "&key=" + StaticUtils.IMOCCA_X_LC_KEY + "&time=$time&domainName=$domainName" MessageDigest md = MessageDigest.getInstance("MD5"); byte[] md5 = md.digest(token.getBytes()); return byteToHex(md5) } /** * byte转换16进制字符串 * @param hash * @return */ private static String byteToHex(final byte[] hash) { Formatter formatter = new Formatter(); for (byte b : hash) { formatter.format("%02x", b); } String result = formatter.toString(); formatter.close(); return result; }
MD5解密: