💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 组件源码 ``` /** * @category DES加密 * @param instr * 入参|待加密字符串|{@link java.lang.String} * @param key * 入参|加密密钥|{@link java.lang.String} * @param encstr * 出参|加密后的字符串|{@link java.lang.String} * @return -1 异常<br/> * 1 成功<br/> */ @InParams(param = { @Param(name = "instr", comment = "待加密字符串", type = java.lang.String.class), @Param(name = "key", comment = "加密密钥", type = java.lang.String.class) }) @OutParams(param = { @Param(name = "encstr", comment = "加密后的字符串", type = java.lang.String.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "1", desp = "成功") }) @Component(label = "DES加密", style = "判断型", type = "同步组件", version = "1.0.0", deprecated = false, author = "test", date = "2018-01-19 05:08:46") public static ResultBase P_desEnc(String instr, String key) { String strErr = ""; try { key += " "; SecureRandom random = new SecureRandom(); DESKeySpec desKey = new DESKeySpec(key.getBytes()); // 创建一个密匙工厂,然后用它把DESKeySpec转换成 SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); SecretKey securekey = keyFactory.generateSecret(desKey); // Cipher对象实际完成加密操作 Cipher cipher = Cipher.getInstance("DES"); // 用密匙初始化Cipher对象 cipher.init(Cipher.ENCRYPT_MODE, securekey, random); byte[] by = cipher.doFinal(instr.getBytes()); // EBCD编码 String strRet = ""; for (int i = 0; i < by.length; i++) strRet += Integer.toString(0x200 + by[i], 16).substring(1); return ResultBase.newSuccessResult(strRet); } catch (Exception ex) { AppLog.error(ex); strErr = AppLog.errorMsg(ex); } return ResultBase.newExceptionResult("TPTS0001", "DES加密出现异常:" + strErr); } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/55/4a/554ac9e67422ceb5a8085b0808a06c3b_1868x891.png) # 参数说明及示例 ## 入口参数 待加密字符串:需要加密的字符串,示例: `"abc"` 加密密钥:对待加密字符串加密的密钥,示例: `"123"` ## 出口参数 加密后的字符串:经过加密后的字符串,示例: `__INNER__["result"]`