在在进行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小时内删除。
留言与评论(共有 0 条评论) |