`
lg70124752
  • 浏览: 61533 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Input length must be multiple of 8 when decrypting with padded cipher

    博客分类:
  • java
阅读更多
java.lang.RuntimeException: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
        at us.pinguo.flume.hdfs.ext.source.BlobExtHandler.checkGeo(BlobExtHandler.java:399)
        at us.pinguo.flume.hdfs.ext.source.BlobExtHandler.processEvent(BlobExtHandler.java:232)
        at us.pinguo.flume.hdfs.ext.source.BlobExtHandler.getEvents(BlobExtHandler.java:140)
        at us.pinguo.flume.hdfs.ext.source.HTTPSource$FlumeHTTPServlet.doPost(HTTPSource.java:252)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:767)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
        at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:750)
        at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
        at com.sun.crypto.provider.DESCipher.engineDoFinal(DESCipher.java:314)
        at javax.crypto.Cipher.doFinal(Cipher.java:2087)
        at us.pinguo.flume.hdfs.ext.utils.DES.decryptDES(DES.java:49)
        at us.pinguo.flume.hdfs.ext.utils.DESHelperV2.decryptDESBase64(DESHelperV2.java:96)
        at us.pinguo.flume.hdfs.ext.source.BlobExtHandler.checkGeo(BlobExtHandler.java:386)
        ... 19 more



解决方案
you are calling doFinal multiple times. or at least trying to.

when you read data, not all data arrives or is read into the buffer at once. so you decrypt some and then read again. that is all ok.

but when you do that, you are calling doFinal each time, instead of update. this is wrong and is the cause of the error. instead, replace doFinal with update and then add an extra doFinal once you have finished reading all data (there is a doFinal() that takes no arguments for exactly this reason).

see http://docs.oracle.com/javase/7/docs/api/javax/crypto/Cipher.html

also see http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Electronic_codebook_.28ECB.29 for why ecb mode is often not a good idea (look at the penguin pictures).
分享到:
评论

相关推荐

    JCEPolicyJDK8.zip

    当环境为jdk1.8.0_191之前的版本时,使用jdk自带的AES256...Input length must be multiple of 16 when decrypting with padded cipher,可通过将此附件解压后复制jar包到jre\lib\security 目录进行覆盖,即可解决。

    Kotlin Base64编解码类

    Exception in thread "main" javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher at java.base/...

    Hacking.Secret.Ciphers.with.Python.B00WOY87ZU

    Chapter 8 - Encrypting with the Transposition Cipher Chapter 9 - Decrypting with the Transposition Cipher Chapter 10 - Programming a Program to Test Our Program Chapter 11 - Encrypting and Decrypting ...

    aaes.zip_Adopted

    AES is based on the Rijndael cipher developed by two Belgian cryptographers, Joan Daemen and Vincent Rijmen, who submitted a proposal to NIST during the AES selection process. Rijndael is a family of ...

    NIST SP800-21.pdf

    Today’s information technology security environment consists of highly interactive and powerful computing devices and interconnected systems of systems across global networks where Federal agencies ...

    LockBox2.5

    This version of LockBox has been updated so that it can be used with Tiburon. Creating a version of LockBox that is compatible with Tiburon is not very difficult. All that needed to be done was ...

    2018年8月arrow病毒解码工具

    download this file, and add it to white list in your antivirus 6) run this application WITH ADMINISTRATOR RIGHTS 7) scan local machine (don't move your files - this may compromise the integrity of the...

    python-xtea.tar.gz_The Chain_block_block chain_encryption_xtea

    Python implementation of the XTEA Block Encryption Algorithm. Also includes a CBC decrypt function for decrypting Cipher Block Chain mode encrypted ciphertext.

    DumpXor_decrypting_XOR_friendexe_Known_

    在标题提及的"Program for decrypting a dump using a known xor"中,我们面临的问题是解密一个已经使用特定XOR密钥加密过的dump文件。Dump文件通常包含程序执行时内存中的状态,可能含有敏感信息,因此解密它对于...

    ScienceDecrypting

    8. **.github**:这是一个隐藏目录,通常包含 GitHub 工作流程的配置文件,如 Issue 模板、Pull Request 模板等,表明项目可能使用了 GitHub 的一些高级功能。 综合这些文件,我们可以推测 "ScienceDecrypting" 是...

    Hack Proofing Your Network, Second Edition

    · The Politics, Laws of Security, Classes of Attack, Methodology, Diffing, Decrypting, Brute Force, Unexpected Input, Buffer Overrun, Sniffing, Session Hijacking, Spoofing, Server Holes, Client ...

    Encrypting and decrypting sensitive data using CryptoAPI. (6

    标题中的“Encrypting and decrypting sensitive data using CryptoAPI”指的是使用Windows操作系统提供的CryptoAPI来对敏感数据进行加密和解密的技术。CryptoAPI是微软提供的一组接口,它允许程序员实现安全的加密...

    Android代码-whorlwind

    Whorlwind A reactive wrapper around Android's fingerprint API that handles encrypting/decrypting sensitive ...keyAlias is used when generating a key pair in the KeyStore and should not be shared with an

    Visual C++ 编程资源大全(英文源码 其它)

    in converts the text format (DOS or UNIX) of a file when it is saved in Visual Studio.(39KB)<END><br>78,devtruecolour.zip Use any colour in the Developer Studio IDE(49KB)<END><br>79,openvc_demo.zip...

    hls.min.js

    (e.size)){var r=t._utf8ArrayToStr(e.data),i=new Uint8Array(e.data.subarray(r.length+1));return{key:e.type,info:r,data:i.buffer}}},t._decodeTextFrame=function(e){if(!(e.size)){if("TXXX"===e.type){var r...

    opensc-0.12.0.tar.gz

    NEWS for OpenSC -- History of user visible changes Complete change history is available online: http://www.opensc-project.org/opensc/timeline New in 0.12.0; 2010-12-22 * OpenSC uses a single reader ...

    信息安全_数据安全_DPAPI_and_DPAPI-NG:Decrypting_Al.pdf

    数据保护API(DPAPI)与DPAPI-NG是Windows操作系统中用于加密和解密敏感数据的关键组件,特别是在数据安全领域。...在本文中,我们将深入探讨DPAPI的经典版本及其在Windows 10中的新版本DPAPI-NG,以及它们如何帮助保护...

    开源项目-evantbyrne-crypt.zip

    开源项目-evantbyrne-crypt.zip,Made a small utility for encrypting and decrypting files with AES-256 GCM and Scrypt – feedback appreciated!

    Рисунки для 2ТЭ25КМ_dataутечка_dataхакер_ТПС_

    Decrypting data files

Global site tag (gtag.js) - Google Analytics