Encrypting Objects

Is it at all possible to perform encryption on an object? Using bouncycastle to do RSA assymetric encryption. I have only seen examples of encrypting byte arrays and files.

I have an object of type Student. That basically contains a couple of strings containing valuable data. I would like to encrypt the Student object that encapsulates this data. Is this possible? Or will i be forced to encrypt the contents of this object individually?

Any sample code will also be very helpful

Thanking you in advance

Thee Olde Wizard

[561 byte] By [gandalfgrey] at [2007-9-26 14:04:39]
# 1
If you're object implements the Serializable interface then you can write it out to a byte[] using writeObject() and then encrypt that array.
swatdba at 2007-7-2 15:21:18 > top of Java-index,Security,Cryptography...
# 2
okay but then how would I send that byte array in encrypted form to a servlet, bcos its no longer an objectOutputStream
gandalfgrey at 2007-7-2 15:21:18 > top of Java-index,Security,Cryptography...
# 3
If you need the encrypted byte[] to be sent over as an Object, any array in Java is an object so you shouldn't have a problem there. The servlet will need access to a key to decrypt the array however.
swatdba at 2007-7-2 15:21:18 > top of Java-index,Security,Cryptography...
# 4

yeah thats okay. The servlet will have access to either a keystore or a database that conatins the necessary private key.

But i have found another problem. I am using the bouncycastle implementation, but will this work with an applet in a browser. I have only found examples of assyemtric encryption in applications

Thanks once again

Thee olde wizard

gandalfgrey at 2007-7-2 15:21:18 > top of Java-index,Security,Cryptography...
# 5
I have not been involved with Applets recently at any rate. So maybe someone else will know. I would suspect signing would be necessary. Good luck!
swatdba at 2007-7-2 15:21:18 > top of Java-index,Security,Cryptography...
# 6
Use Sealed Objects
khanna111 at 2007-7-2 15:21:18 > top of Java-index,Security,Cryptography...