Meaningless Drivel is fun!
The moose likes Java in General and the fly likes Object to byte[] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Object to byte[]" Watch "Object to byte[]" New topic

Object to byte[]

Thai C. Tran

Joined: Jul 05, 2009
Posts: 26
Dear all,

I use the code below to write object into file. However, in the final file, i also have the class name and the signature of the class. Due to the security problem, i want to get rid of them. How can I implement it in Java ?

David O'Meara

Joined: Mar 06, 2001
Posts: 13459

you can provide your own writeObject/readObject implementations for your object types rather than relying on the defaults.
I'm not sure what 'security issues' you're trying to resolve, but those methods are how you implement customized Object serialization.
Thai C. Tran

Joined: Jul 05, 2009
Posts: 26
I am developing a cryptography app by using java. In the end of the process, password from user is encrypted and added with some other parameters and meta data into an object, which will be saved into file for the later usage. Therefore, leaving some footprints in the final file is not good. The file will be also read by another program (in C++), so the structure of the file is fixed as well. The content of the object is correct right now, except when being converted into byte array, Java automatically add more information into the final data
I agree. Here's the link:
subject: Object to byte[]
It's not a secret anymore!