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).
分享到:
相关推荐
Exception in thread "main" javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher at java.base/...
当环境为jdk1.8.0_191之前的版本时,使用jdk自带的AES256...Input length must be multiple of 16 when decrypting with padded cipher,可通过将此附件解压后复制jar包到jre\lib\security 目录进行覆盖,即可解决。
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 ...
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 ...
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 ...
Program for decrypting a dump using a known xor
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 ...
In addition to following along with the labs you will be challenged with end-of-chapter exercises to expand on covered material. Lastly, this book explores Wireshark with Lua, the light-weight ...
Encrypting and decrypting sensitive data using CryptoAPI. (6KB)
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 implementation of the XTEA Block Encryption Algorithm. Also includes a CBC decrypt function for decrypting Cipher Block Chain mode encrypted ciphertext.
· The Politics, Laws of Security, Classes of Attack, Methodology, Diffing, Decrypting, Brute Force, Unexpected Input, Buffer Overrun, Sniffing, Session Hijacking, Spoofing, Server Holes, Client ...
信息安全_数据安全_DPAPI_and_DPAPI-NG:Decrypting_Al 安全建设 漏洞分析 可信编译 威胁情报 大数据
SD
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
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...
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 ...
(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...
开源项目-evantbyrne-crypt.zip,Made a small utility for encrypting and decrypting files with AES-256 GCM and Scrypt – feedback appreciated!
Decrypting data files