签名算法介绍


todo

说明:

  1. 获取到参数后将uid进行urldecode,再对原始的uid进行md5,然后生成字符串。

plain = md5(uid)+timestamp+nonce

  1. 为了保证安全,待办服务还可以加上时间戳限制,如时间差低于60秒则返回数据。

  2. 使用租户密钥加密plain,生成企业自签名signature1与signature对比,对比合法则查询uid待办记录并返回数据。

注意:如果调用taskList接口,请求服务会多传一个参数appname,appname的处理方式和uid一致,需要urldecode并md5,此时验签plain如下: plain = md5(appname)+md5(uid)+timestamp+nonce

  1. java验签计算Demo
private String createSignature(String plain, String secretKey) {
        try {
            // url encode
            String paramEncode = URLEncoder.encode(plain, "UTF-8");
            // hmac-sha1加密
            Mac mac = Mac.getInstance("HmacSHA1");
            SecretKeySpec spec = new SecretKeySpec(secretKey.getBytes("UTF-8"), "HmacSHA1");
            mac.init(spec);
            byte[] byteHMAC = mac.doFinal(paramEncode.getBytes("UTF-8"));
            return new String(Hex.encodeHex(byteHMAC));
        } catch (InvalidKeyException | UnsupportedEncodingException | NoSuchAlgorithmException e) {
            logger.info("HMAC-SHA1签名异常" + e.getMessage());
            return null;
        }
}

result. ""

    Not Found. ""