cn.hutool.crypto.symmetric.AES Java Examples
The following examples show how to use
cn.hutool.crypto.symmetric.AES.
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: SecurityTools.java From jeecg-cloud with Apache License 2.0 | 6 votes |
public static SecurityResp valid(SecurityReq req) { SecurityResp resp=new SecurityResp(); String pubKey=req.getPubKey(); String aesKey=req.getAesKey(); String data=req.getData(); String signData=req.getSignData(); RSA rsa=new RSA(null, Base64Decoder.decode(pubKey)); Sign sign= new Sign(SignAlgorithm.SHA1withRSA,null,pubKey); byte[] decryptAes = rsa.decrypt(aesKey, KeyType.PublicKey); //log.info("rsa解密后的秘钥"+ Base64Encoder.encode(decryptAes)); AES aes = SecureUtil.aes(decryptAes); String dencrptValue =aes.decryptStr(data); //log.info("解密后报文"+dencrptValue); resp.setData(new JSONObject(dencrptValue)); boolean verify = sign.verify(dencrptValue.getBytes(), Base64Decoder.decode(signData)); resp.setSuccess(verify); return resp; }
Example #2
Source File: SecurityTools.java From jeecg-boot-with-activiti with MIT License | 6 votes |
public static SecurityResp valid(SecurityReq req) { SecurityResp resp=new SecurityResp(); String pubKey=req.getPubKey(); String aesKey=req.getAesKey(); String data=req.getData(); String signData=req.getSignData(); RSA rsa=new RSA(null, Base64Decoder.decode(pubKey)); Sign sign= new Sign(SignAlgorithm.SHA1withRSA,null,pubKey); byte[] decryptAes = rsa.decrypt(aesKey, KeyType.PublicKey); //log.info("rsa解密后的秘钥"+ Base64Encoder.encode(decryptAes)); AES aes = SecureUtil.aes(decryptAes); String dencrptValue =aes.decryptStr(data); //log.info("解密后报文"+dencrptValue); resp.setData(new JSONObject(dencrptValue)); boolean verify = sign.verify(dencrptValue.getBytes(), Base64Decoder.decode(signData)); resp.setSuccess(verify); return resp; }
Example #3
Source File: SecurityTools.java From teaching with Apache License 2.0 | 6 votes |
public static SecurityResp valid(SecurityReq req) { SecurityResp resp=new SecurityResp(); String pubKey=req.getPubKey(); String aesKey=req.getAesKey(); String data=req.getData(); String signData=req.getSignData(); RSA rsa=new RSA(null, Base64Decoder.decode(pubKey)); Sign sign= new Sign(SignAlgorithm.SHA1withRSA,null,pubKey); byte[] decryptAes = rsa.decrypt(aesKey, KeyType.PublicKey); //log.info("rsa解密后的秘钥"+ Base64Encoder.encode(decryptAes)); AES aes = SecureUtil.aes(decryptAes); String dencrptValue =aes.decryptStr(data); //log.info("解密后报文"+dencrptValue); resp.setData(new JSONObject(dencrptValue)); boolean verify = sign.verify(dencrptValue.getBytes(), Base64Decoder.decode(signData)); resp.setSuccess(verify); return resp; }
Example #4
Source File: SecurityTools.java From jeecg-boot with Apache License 2.0 | 6 votes |
public static SecurityResp valid(SecurityReq req) { SecurityResp resp=new SecurityResp(); String pubKey=req.getPubKey(); String aesKey=req.getAesKey(); String data=req.getData(); String signData=req.getSignData(); RSA rsa=new RSA(null, Base64Decoder.decode(pubKey)); Sign sign= new Sign(SignAlgorithm.SHA1withRSA,null,pubKey); byte[] decryptAes = rsa.decrypt(aesKey, KeyType.PublicKey); //log.info("rsa解密后的秘钥"+ Base64Encoder.encode(decryptAes)); AES aes = SecureUtil.aes(decryptAes); String dencrptValue =aes.decryptStr(data); //log.info("解密后报文"+dencrptValue); resp.setData(new JSONObject(dencrptValue)); boolean verify = sign.verify(dencrptValue.getBytes(), Base64Decoder.decode(signData)); resp.setSuccess(verify); return resp; }
Example #5
Source File: PasswordDecoderFilter.java From smaker with GNU Lesser General Public License v3.0 | 5 votes |
private static String decryptAES(String data, String pass) { AES aes = new AES(Mode.CBC, Padding.NoPadding, new SecretKeySpec(pass.getBytes(), KEY_ALGORITHM), new IvParameterSpec(pass.getBytes())); byte[] result = aes.decrypt(Base64.decode(data.getBytes(StandardCharsets.UTF_8))); return new String(result, StandardCharsets.UTF_8); }
Example #6
Source File: HelloWorldController.java From spring-boot-demo with MIT License | 5 votes |
@RequestMapping("/test") public String test(String p1, String p2) { AES aes = new AES(Mode.OFB, Padding.NoPadding, p1.getBytes(), "9875462154789536".getBytes()); String decryptStr = aes.decryptStr(p2, CharsetUtil.CHARSET_UTF_8); return decryptStr; }
Example #7
Source File: CryptoExample.java From yue-library with Apache License 2.0 | 5 votes |
@GetMapping("/secure") public Result<?> secure() { // AES加密 AES aes = SecureSingleton.getAES(); aes.encryptBase64(""); aes.decryptStr(""); // RSA加密-公钥加密,私有解密 RSA rsa = SecureSingleton.getRSA(); rsa.encryptBcd("", KeyType.PublicKey); rsa.decryptStrFromBcd("", KeyType.PrivateKey); return ResultInfo.success(); }
Example #8
Source File: CryptoExample.java From yue-library with Apache License 2.0 | 5 votes |
@GetMapping("/secure") public Result<?> secure() { // AES加密 AES aes = SecureSingleton.getAES(); aes.encryptBase64(""); aes.decryptStr(""); // RSA加密-公钥加密,私有解密 RSA rsa = SecureSingleton.getRSA(); rsa.encryptBcd("", KeyType.PublicKey); rsa.decryptStrFromBcd("", KeyType.PrivateKey); return ResultInfo.success(); }
Example #9
Source File: SysLoginController.java From hdw-dubbo with Apache License 2.0 | 5 votes |
/** * 加密 * @param data * @return */ @ApiOperation(value = "加密", notes = "加密") @ApiImplicitParams({ @ApiImplicitParam(paramType = "query", name = "data", value = "待加密字符串", required = false, dataType = "String"), }) @GetMapping("/sys/encrypt") public String encrypt(String data){ /** AES加解密 */ AES aes = new AES(Mode.CBC, Padding.PKCS5Padding, "1234567812345678".getBytes(), "1234567812345678".getBytes()); // 解密 String s = aes.encryptBase64(data); return s; }
Example #10
Source File: SysLoginController.java From hdw-dubbo with Apache License 2.0 | 5 votes |
/** * 解密 * @param encrypt * @return */ private String decrypt(String encrypt) { /** AES加解密 */ AES aes = new AES(Mode.CBC, Padding.PKCS5Padding, "1234567812345678".getBytes(), "1234567812345678".getBytes()); // 解密 String s= aes.decryptStr(encrypt).replace("\"", ""); return s; }
Example #11
Source File: PasswordDecoderFilter.java From albedo with GNU Lesser General Public License v3.0 | 5 votes |
public static String decryptAes(String data, String pass) { AES aes = new AES(Mode.CBC, Padding.NoPadding, new SecretKeySpec(pass.getBytes(), KEY_ALGORITHM), new IvParameterSpec(pass.getBytes())); byte[] result = aes.decrypt(Base64.decode(data.getBytes(StandardCharsets.UTF_8))); return new String(result, StandardCharsets.UTF_8); }
Example #12
Source File: ShopBeanConfig.java From mall4j with GNU Affero General Public License v3.0 | 4 votes |
@Bean public AES tokenAes() { return new AES(shopBasicConfig.getTokenAesKey().getBytes()); }
Example #13
Source File: SecureSingleton.java From yue-library with Apache License 2.0 | 2 votes |
/** * 获取自动配置单例 - AES * * @return AES 单例 */ public static AES getAES() { return Singleton.get(AES.class); }