身份证2要素银行卡234要素实名核验-企业专享(1072)-支持文档

[TOC] 重要:本界面内容 **将要废弃** ~~##(一)、加密版的规则~~ 算法:AES 模式:ECB 补码方式:PKCS5Padding ~~##(二)、步骤~~ 1.准备加密的密钥,**取前16位** [点此查看](https://www.showapi.com/console#/myApp "点此查看") 我是接口使用者>我的应用>密钥 2.使用AES/ECB/PKCS5Padding算法进行加密 3.将加密结果进行base64转化 4.对加密后的数据做UrlEncode处理 ~~##(三)、加解密示例如下~~ package service.AesUtil import javax.crypto.Cipher import javax.crypto.spec.SecretKeySpec import org.apache.commons.codec.binary.Base64 class AesUtil{ /** * 密钥算法 */ private static final String ALGORITHM = "AES"; /** * 加解密算法/模式/方式 */ private static final String ALGORITHM_STR = "AES/ECB/PKCS5Padding"; /** * 加密 * @param sSrc * @param sKey * @return * @throws Exception */ public static String Encrypt(String sSrc, String sKey) throws Exception { if (sKey == null) { System.out.print("Key为空null"); return null; } // 判断Key是否为16位 if (sKey.length() != 16) { System.out.print("Key长度不是16位"); return null; } byte[] raw = sKey.getBytes("utf-8"); SecretKeySpec skeySpec = new SecretKeySpec(raw, ALGORITHM); Cipher cipher = Cipher.getInstance(ALGORITHM_STR); cipher.init(Cipher.ENCRYPT_MODE, skeySpec); byte[] encrypted = cipher.doFinal(sSrc.getBytes("utf-8")); return Base64.encodeBase64String(encrypted); } /** * 解密 * @param sSrc * @param sKey * @return * @throws Exception */ public static String Decrypt(String sSrc, String sKey) throws Exception { try { // 判断Key是否正确 if (sKey == null) { System.out.print("Key为空null"); return null; } // 判断Key是否为16位 if (sKey.length() != 16) { System.out.print("Key长度不是16位"); return null; } byte[] raw = sKey.getBytes("utf-8"); SecretKeySpec skeySpec = new SecretKeySpec(raw, ALGORITHM); Cipher cipher = Cipher.getInstance(ALGORITHM_STR); cipher.init(Cipher.DECRYPT_MODE, skeySpec); byte[] encrypted1 = Base64.decodeBase64(sSrc); try { byte[] original = cipher.doFinal(encrypted1); String originalString = new String(original, "utf-8"); return originalString; } catch (Exception e) { System.out.println(e.toString()); return null; } } catch (Exception ex) { System.out.println(ex.toString()); return null; } } } ~~##(四)、在线加密工具~~ AES:http://tool.chacuo.net/cryptaes ![](https://oss.showapi.com/doc/3217/4/6575431d45f24e3a83ed258465e4ca60.png) URLEncode:http://tool.chinaz.com/tools/urlencode.aspx ![](https://oss.showapi.com/doc/3217/4/6b5e46dd246a4e1886669b0f256dfc89.png)