• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

javax.crypto.BadPaddingException: Given final block not properly padded

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all !
I'm very new to spring and eclipse, and I'm currently working on a codeEnhancement project.
It's my second day to post on this Forum(the only one forum i ever entered), and I think i'm already falling in love with this place!

I'm currently trying to decrypt a password from a decrypt file and use the password to connect to oracle database.
However, I've encourntered a number of errors with this

the first Error is when i set my proxy in eclipse, The error log pops out and states that:
Keybinding conflicts occurred.They may interfere with normail accelerator operation
org.eclipse.core.runtime.AssertionFailedException:assertion failed:
Unhandled event loop exception

Any help will be much appreciated



When i run my codes, it hits the following error:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'PoolingDao' defined in class path resource [jobmgmt_beans.xml]: Invocation of init method failed; nested exception is javax.crypto.BadPaddingException: Given final block not properly padded
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at net.CodeEnhancement.JobMgmt.main(JobMgmt.java:118)
Caused by: javax.crypto.BadPaddingException: Given final block not properly padded
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.AESCipher.engineDoFinal(DashoA13*..)
at javax.crypto.Cipher.doFinal(DashoA13*..)
at net.CodeEnhancement.Scrambler.unscramble(Scrambler.java:76)
at net.CodeEnhancement.JdbcDao.decrypt(JdbcDao.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1544)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 12 more


I've read some about BadPaddingException and there are people suggeting to store the encrypted variable in byte[].
I've tried it inside my DAO, but it still hits the same error during runtime.

Below is my JdbcDao.java:



and my jobmgmt_beans.xml which has the bean id= PoolingDao:



Any help will be much appreciated
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While we can't be sure what's going on since we don't know what the Scrambler and Encryptor classes are doing, calling "toString" on the output is a read flag - assuming that it converts a byte[] to a string, not specifying the encoding makes the code platform-dependent.

Make sure the key and the ciphertext are never stored (or used) as strings anywhere.
 
sze sze chan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:While we can't be sure what's going on since we don't know what the Scrambler and Encryptor classes are doing, calling "toString" on the output is a read flag - assuming that it converts a byte[] to a string, not specifying the encoding makes the code platform-dependent.

Make sure the key and the ciphertext are never stored (or used) as strings anywhere.



Hi, thank you for your reply, I'm still keep hitting the same BadPaddingException
I will really appreciate it if you could help, thanks

this is my Scramble.java:


and Encryptor.java
 
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic