Java Code Examples for com.jfinal.kit.HashKit#md5()

The following examples show how to use com.jfinal.kit.HashKit#md5() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModelExt.java    From jfinal-ext3 with Apache License 2.0 6 votes vote down vote up
/**
 * redis key for attrs' values
 * @param flag : ids or id store
 * @return data[s]:md5(concat(columns' value))
 */
private String redisColumnKey(SqlpKit.FLAG flag) {
	StringBuilder key = new StringBuilder(this._getUsefulClass().toGenericString());
	String[] attrs = this._getAttrNames();
	Object val;
	for (String attr : attrs) {
		val = this.get(attr);
		if (null == val) {
			continue;
		}
		key.append(val.toString());
	}
	key = new StringBuilder(HashKit.md5(key.toString()));
	if (flag.equals(SqlpKit.FLAG.ONE)) {
		return "data:"+key;
	}
	return "datas:"+key;
}
 
Example 2
Source File: ApiInterceptor.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
private String createLocalSign(Controller controller) {
    String queryString = controller.getRequest().getQueryString();
    Map<String, String[]> params = controller.getRequest().getParameterMap();

    String[] keys = params.keySet().toArray(new String[0]);
    Arrays.sort(keys);
    StringBuilder query = new StringBuilder();
    for (String key : keys) {
        if ("sign".equals(key)) {
            continue;
        }

        //只对get参数里的进行签名
        if (queryString.indexOf(key + "=") == -1) {
            continue;
        }

        String value = params.get(key)[0];
        query.append(key).append(value);
    }
    query.append(apiSecret);
    return HashKit.md5(query.toString());
}
 
Example 3
Source File: ShowapiExpressQuerier.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static String signRequest(Map<String, Object> params, String appkey) {
    String[] keys = params.keySet().toArray(new String[0]);
    Arrays.sort(keys);

    StringBuilder builder = new StringBuilder();
    for (String key : keys) {
        Object value = params.get(key);
        if (value != null && StrUtil.areNotEmpty(key, value.toString())) {
            builder.append(key).append(value);
        }
    }
    builder.append(appkey);
    return HashKit.md5(builder.toString());
}
 
Example 4
Source File: SignUtils.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static String signForRequest(Map<String, String> params, String secret) {
    String[] keys = params.keySet().toArray(new String[0]);
    Arrays.sort(keys);

    StringBuilder query = new StringBuilder();
    for (String key : keys) {
        String value = params.get(key);
        if (StrUtil.areNotEmpty(key, value)) {
            query.append(key).append(value);
        }
    }
    query.append(secret);
    return HashKit.md5(query.toString());
}
 
Example 5
Source File: CookieUtil.java    From jboot with Apache License 2.0 4 votes vote down vote up
private static String encrypt(String secretKey, Object saveTime, Object maxAgeInSeconds, String value) {
    if (JbootWebConfig.DEFAULT_COOKIE_ENCRYPT_KEY.equals(secretKey)) {
        log.warn("warn!!! encrypt key is defalut value. please config \"jboot.web.cookieEncryptKey = xxx\" in jboot.properties ");
    }
    return HashKit.md5(secretKey + saveTime.toString() + maxAgeInSeconds.toString() + value);
}
 
Example 6
Source File: ShowapiExpressQuerier.java    From jpress with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public List<ExpressInfo> query(ExpressCompany company, String num) {

    String appId = JPressOptions.get("express_api_appid");
    String appSecret = JPressOptions.get("express_api_appsecret");

    String param = "{\"com\":\"" + company.getCode() + "\",\"num\":\"" + num + "\"}";
    String sign = HashKit.md5(param + appSecret + appId);
    HashMap params = new HashMap();
    params.put("showapi_appid", appId);
    params.put("com", sign);
    params.put("nu", num);
    params.put("contentType", "bodyString");
    params.put("showapi_sign", signRequest(params, appSecret));


    String result = HttpUtil.httpGet("http://route.showapi.com/64-19", params);
    if (StrUtil.isBlank(result)) {
        return null;
    }

    try {
        JSONObject object = JSONObject.parseObject(result);
        JSONObject body = object.getJSONObject("showapi_res_body");
        if (body != null) {
            JSONArray jsonArray = body.getJSONArray("data");
            if (jsonArray != null && jsonArray.size() > 0) {
                List<ExpressInfo> list = new ArrayList<>();
                for (int i = 0; i < jsonArray.size(); i++) {
                    JSONObject expObject = jsonArray.getJSONObject(i);
                    ExpressInfo ei = new ExpressInfo();
                    ei.setInfo(expObject.getString("context"));
                    ei.setTime(expObject.getString("time"));
                    list.add(ei);
                }
                return list;
            }
        }
    } catch (Exception ex) {
        LOG.error(ex.toString(), ex);
    }

    LOG.error(result);

    return null;
}
 
Example 7
Source File: RandomKit.java    From jfinal-ext3 with Apache License 2.0 2 votes vote down vote up
/**
 *  随机字符串再 md5:UUID方式
 * @return
 */
public static String randomMD5Str(){
	return HashKit.md5(randomStr());
}