ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 组件源码 ``` /** * <b>方法描述:</b> MD5十进制字符串 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-09-10 10:31:16 <br/> * * @param text * 入参|待编码字符串|{@link java.lang.String} * @param charset * 入参|字符串编码|{@link java.lang.String} * @param nlen * 入参|返回长度(0-实际长度,<0左截取,>0右边截取)|int * @param out * 出参|返回字符串|{@link java.lang.String} * @return 0 失败<br/> * 1 成功<br/> */ @Component(label = "MD5十进制字符串", style = "判断型", type = "同步组件", version = "1.0.0", deprecated = false, author = "admin", date = "2018-09-10 10:31:16") @InParams(param = { @Param(name = "text", comment = "待编码字符串", type = java.lang.String.class), @Param(name = "charset", comment = "字符串编码", type = java.lang.String.class), @Param(name = "nlen", comment = "返回长度(0-实际长度,<0左截取,>0右边截取)", type = int.class) }) @OutParams(param = { @Param(name = "out", comment = "返回字符串", type = java.lang.String.class) }) @Returns(returns = { @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) public static ResultBase P_md5DecimalStr(String text, String charset, int nlen) { try { charset = ((charset==null||charset=="")?"UTF-8":charset); byte[] bs = text.getBytes(charset); MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(bs); String hex = new BigInteger(1, digest.digest()).toString(10); int hexlen = hex.length(); if( nlen == 0 || Math.abs(nlen)>= hexlen ) { return ResultBase.newSuccessResult(hex); } else if( nlen > 0 ) { return ResultBase.newSuccessResult(hex.substring(hexlen-nlen)); } else { return ResultBase.newSuccessResult(hex.substring(0,0-nlen)); } }catch(Exception ex ) { AppLog.error(ex); return ResultBase.newFailureResult("TPTS0009", "待编码内容不支持"); } } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/93/98/93987ad3ac3a9edd0c5698df2b2a85ec_1868x892.png) # 参数说明及示例 ## 入口参数 待编码字符串:需要进行编码的字符串,示例: `"abc"` 字符串编码:设置字符串编码,示例: `"utf-8"` 返回长度(0-实际长度,<0左截取,>0右边截取):返回的字符串长度,示例: `0` ## 出口参数 返回字符串:经过编码后的字符串,示例: `__INNER__["result"]`