• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with decrypting my data (javax.crypto)  RSS feed

 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
What could it be saved as?

Vector<Xxxxx>.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not just Vector<byte[]>?
byte[] is an object type just as much as Object is.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!