当前位置: 首页 > news >正文

中介网站模板专用车网站建设多少钱

中介网站模板,专用车网站建设多少钱,免费做网站的,嘉兴门户网站建设我更改了一些代码行,以保证大文件的加密.现在我遇到了问题,解密不起作用.我收到以下错误消息/异常#xff1a;Error encrypting/decrypting fileat Algorithmus.Encryptor.doCrypto(Encryptor.java:71)at Algorithmus.Encryptor.decrypt(Encryptor.java:39)at GUI.MainWindow$…我更改了一些代码行,以保证大文件的加密.现在我遇到了问题,解密不起作用.我收到以下错误消息/异常Error encrypting/decrypting fileat Algorithmus.Encryptor.doCrypto(Encryptor.java:71)at Algorithmus.Encryptor.decrypt(Encryptor.java:39)at GUI.MainWindow$encryptThread.run(MainWindow.java:838)Caused by: javax.crypto.BadPaddingException: Given final block not properly paddedat com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:966)at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:824)at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:436)at javax.crypto.Cipher.doFinal(Cipher.java:2165)at Algorithmus.Encryptor.doCrypto(Encryptor.java:60)... 2 more我试图将Transoformation参数更改为AES / CBC / PKCS5Padding,但这没有任何效果.有谁知道,如何优化给定的代码private static final String ALGORITHM AES;private static final String TRANSFORMATION AES;public static void encrypt(String key, File inputFile, File outputFile)throws ExtendedException {doCrypto(Cipher.ENCRYPT_MODE, key, inputFile, outputFile);}public static void decrypt(String key, File inputFile, File outputFile)throws ExtendedException {doCrypto(Cipher.DECRYPT_MODE, key, inputFile, outputFile);}private static void doCrypto(int cipherMode, String key, File inputFile,File outputFile) throws ExtendedException {try {Key secretKey new SecretKeySpec(key.getBytes(), ALGORITHM);Cipher cipher Cipher.getInstance(TRANSFORMATION);cipher.init(cipherMode, secretKey);FileInputStream inputStream new FileInputStream(inputFile);CipherOutputStream out new CipherOutputStream(new FileOutputStream(outputFile), cipher);byte[] buffer new byte[8192];byte[] outputBytes null;FileOutputStream outputStream new FileOutputStream(outputFile);int count;while ((count inputStream.read(buffer)) 0){out.write(buffer, 0, count);outputBytes cipher.doFinal(buffer);}inputStream.close();outputStream.close();} catch (NoSuchPaddingException | NoSuchAlgorithmException| InvalidKeyException | BadPaddingException| IllegalBlockSizeException | IOException ex) {throw new ExtendedException(Error encrypting/decrypting file, ex);}}解决方法:只需使用CipherOutputStream即可.不要调用cipher.doFinal(缓冲区),也不要忘记关闭输出流.FileInputStream inputStream new FileInputStream(inputFile);FileOutputStream fileout new FileOutputStream(outputFile);CipherOutputStream out new CipherOutputStream(fileout , cipher);try {byte[] buffer new byte[8192];int count;while ((count inputStream.read(buffer)) 0) {out.write(buffer, 0, count);}} finally {out.close();inputStream.close();}CipherOutputStream为您管理密码.它将在关闭流并刷新内部缓冲区时调用doFinal.标签java,padding,cryptography,encryption,aes来源 https://codeday.me/bug/20190628/1311548.html
http://www.huolong8.cn/news/41912/

相关文章:

  • wix做的网站深圳计算机速成班培训
  • 网站地图怎么弄搜索网站的浏览器
  • 多语言网站系统曙光建设有限公司网站
  • 深圳营销型网站建设哪家好wordpress建立论坛网站
  • 可以做微网站的第三方平台有哪些公司网站后台如何上传视频
  • 建网站流程 知乎寻找常州微信网站建设
  • 淮南家政网站建设地址北京公司注册流程及需要的材料
  • 图书馆网站建设与评价研究福州网站设计软件公司
  • 个人门户网站备案做外贸网站注意事项
  • 京东商城网站建设教程南通网站建设方案
  • 网站建设属于现代服务吗制作宣传图片的软件app
  • 找别人做网站需要注意什么线上营销方式6种
  • 做信息发布类网站用什么语言做什么网站开发最简单
  • 上海网站建设培训sem和seo有什么区别
  • 做教师知识网站有哪些活动策划流程及细节
  • 联通 网站备案什么网站建设策划方案 论文
  • 做一个网站怎么做的宁波市网站建设
  • 个人网站建设联系电话丹阳seo公司
  • 手机网站开发 c做一款网页游戏需要多少钱
  • 微信公众号app下载安装辽宁网络优化方法
  • 微信登录 网站开发刚做的网站怎么才能搜到我
  • 中国移动网站建设情况分析搭建论坛网站的流程
  • 专做充电器的网站注册公司流程和费用
  • 微信开放平台官方网站学前端有必要找培训机构吗
  • 建设网站公开教学视频dede无法一键更新网站
  • 网站自动发送邮件wordpress主題改豎文
  • 保山公司做网站网页开发哪家好
  • 创建网站 英文帝国程序和WordPress
  • 企必搜做网站肇庆手机台app下载
  • 17网站一起做网店新塘wordpress关注微信登陆