• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Help with decrypting my data (javax.crypto)

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been trying to write two seperate classes for encypting and decrypting data for my test web app, but when I run the decryption class I get the folowing error



Basically I'm passing the data to be encrypted into the Encyption class via a Vector and returning a second Vector of encrypted data.
Then to decrypt the data, I do the same... pass a Vector of encrypted data into the Decryption class and return a Vector of 'plain text'.

Here is the Decryption class (bold text is line 50):



Any help greatly appreciated

KS
[ January 08, 2008: Message edited by: Keith Seller ]
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vector<String> vEncrypted


This looks suspicious. Encrypted data is binary data - you can't store it in strings (unless you perform a binary-to-ASCII conversion like base64 first).

One of the common reasons for getting a BadPaddingException is using strings to store encrypted data.
 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What could it be saved as?

Vector<Xxxxx>.
 
Ulf Dittmer
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Either as String (with the binary data ASCII-encoded), or as an Object you define that encapsulates the byte array.
 
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not just Vector<byte[]>?
byte[] is an object type just as much as Object is.
 
permaculture is largely about replacing oil with people. And one tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic