Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to encrypt/decrypt Objects and cast them back

801487Dec 2 2008 — edited Dec 6 2008
Hi Friends,
I have a "Packet" class with attributes like message, timestamp, key, source, destination etc. This packet basically contains the message that gets transferred along with the public/private key and the timestamp. Now I would like to encrypt this message before I send it across the socket. So can someone please tell me how to do this???

This is what i tried:
I created a Person object and populated it with message, public key, timestamp etc

Then I encrypted the Person object with a private key and got a String back.

Then, I sent the encrypted text across the socket

On receiving end, I retrieved  the String and decrypted it using the public key

But now, I want to retrieve the Person object and here I fail because all the 
text is not readable and I cannot use cast it back to Person class
Can someone please help me and give some pointers how to do this sort of thing....

Thanks in Advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 3 2009
Added on Dec 2 2008
6 comments
413 views