• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

BadpaddingException

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All:

I am trying to decrypt the data using Blowfish algorithm and am using the same key that was used to encrypt the data.

I am getting the following exception :

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

part of the code where i am decrypting the code
-----------------------------------------------
byte[] b =new String("19BA7C8BEEC31234").getBytes();
Cipher decipher = Cipher.getInstance(essoAlgorithm);
decipher.init(Cipher.DECRYPT_MODE, essoKeySpec);
System.out.println("deciphered is " + new String(decipher.doFinal(b)));
-----------------------------------------------

Can anyone throw some light on how to solve the above exception .

Thanks
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Venkatesh Kumar:
new String("19BA7C8BEEC31234").getBytes();

Are you thinking this treats the string as a hex string, turning it into 8 bytes? If so, sorry but that won't do it. You'll end up with the byte array { 31, 39, 42, 41, 37, 43, ... }

If not, are you sure that "19BA7C8BEEC31234" is a correctly encrypted string for that algorithm?
 
He got surgery to replace his foot with a pig. He said it was because of this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic