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

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?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic