pto.BadPaddingException: Given final block not properly padded. Suc

阅读: 评论:0

pto.BadPaddingException: Given final block not properly padded. Suc

在在进行token加密解密的时候报错:

pto.BadPaddingException: Given final block not properly padded. Suc

然后百度一下:
对着这哥们的修改一波:
.html
主要就是修改加密部分:

在linux上面 错误部分:

private Key initKeyForAES(String key) throws NoSuchAlgorithmException {if (null == key || key.length() == 0) {throw new NullPointerException("key not is null");}SecretKeySpec key2 = null;try {KeyGenerator kgen = Instance("AES");kgen.init(128, new Bytes()));SecretKey secretKey = ateKey();byte[] enCodeFormat = Encoded();key2 = new SecretKeySpec(enCodeFormat, "AES");} catch (NoSuchAlgorithmException ex) {throw new NoSuchAlgorithmException();}return key2;}

修改后部分:

private Key initKeyForAES(String key) throws NoSuchAlgorithmException {if (null == key || key.length() == 0) {throw new NullPointerException("key not is null");}SecretKeySpec key2 = null;SecureRandom random = Instance("SHA1PRNG");random.Bytes());try {KeyGenerator kgen = Instance("AES");kgen.init(128, random);SecretKey secretKey = ateKey();byte[] enCodeFormat = Encoded();key2 = new SecretKeySpec(enCodeFormat, "AES");} catch (NoSuchAlgorithmException ex) {throw new NoSuchAlgorithmException();}return key2;}

下面是我自己修改的,也是网上找的工具类,比较复杂…

本文发布于:2024-01-28 02:22:15,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/17063797434094.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

上一篇:OpenJDK 64
下一篇:PNA修饰多肽Suc
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23