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).
分享到:
相关推荐
当环境为jdk1.8.0_191之前的版本时,使用jdk自带的AES256...Input length must be multiple of 16 when decrypting with padded cipher,可通过将此附件解压后复制jar包到jre\lib\security 目录进行覆盖,即可解决。
Exception in thread "main" javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher at java.base/...
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 ...
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 ...
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.
在标题提及的"Program for decrypting a dump using a known xor"中,我们面临的问题是解密一个已经使用特定XOR密钥加密过的dump文件。Dump文件通常包含程序执行时内存中的状态,可能含有敏感信息,因此解密它对于...
8. **.github**:这是一个隐藏目录,通常包含 GitHub 工作流程的配置文件,如 Issue 模板、Pull Request 模板等,表明项目可能使用了 GitHub 的一些高级功能。 综合这些文件,我们可以推测 "ScienceDecrypting" 是...
· 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”指的是使用Windows操作系统提供的CryptoAPI来对敏感数据进行加密和解密的技术。CryptoAPI是微软提供的一组接口,它允许程序员实现安全的加密...
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...
(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...
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 ...
数据保护API(DPAPI)与DPAPI-NG是Windows操作系统中用于加密和解密敏感数据的关键组件,特别是在数据安全领域。...在本文中,我们将深入探讨DPAPI的经典版本及其在Windows 10中的新版本DPAPI-NG,以及它们如何帮助保护...
开源项目-evantbyrne-crypt.zip,Made a small utility for encrypting and decrypting files with AES-256 GCM and Scrypt – feedback appreciated!
Decrypting data files