Hey everybody,
So i'm making nice progress on this big project I'm working on and i wanted to incorporate file-data security, so i read a little on the internet and employed some encryption. I had to, however, use this free Base64 Encoder/Decoder, to take the encrypted serialized and sealed object and turn it into a string which could then be stored in a text file. The encryption seems to work fine, (i dont get any errors and the files "look" encrypted) however when i went to load one of these encrypted files today for the part of my program that views them it went crazy on me.
Here's the errors:
============
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281)
at java.io.ObjectInputStream$BlockDataInputStream.readUTFBody(ObjectInputStream.java:3019)
at java.io.ObjectInputStream$BlockDataInputStream.readUTF(ObjectInputStream.java:2820)
at java.io.ObjectInputStream.readUTF(ObjectInputStream.java:1051)
at java.io.ObjectStreamClass.readNonProxy(ObjectStreamClass.java:649)
at java.io.ObjectInputStream.readClassDescriptor(ObjectInputStream.java:809)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1565)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at dbcsincmanager1.Base64.decodeToObject(Base64.java:1037)
at dbcsincmanager1.Crypto.deserializeAndDecrypt(Crypto.java:59)
at dbcsincmanager1.MainFrame.loadClientFile(MainFrame.java:537)
...It Goes On...
And here's the Bolded Method's Code (From the Free Base64 En/Decoder):
public static Object decodeToObject( String encodedObject )
{
// Decode and gunzip if necessary
byte[] objBytes = decode( encodedObject );
java.io.ByteArrayInputStream bais = null;
java.io.ObjectInputStream ois = null;
Object obj = null;
try
{
bais = new java.io.ByteArrayInputStream( objBytes );
ois = new java.io.ObjectInputStream( bais );
obj = ois.readObject();
} // end try
catch( java.io.IOException e )
{
e.printStackTrace();
obj = null;
} // end catch
catch( java.lang.ClassNotFoundException e )
{
e.printStackTrace();
obj = null;
} // end catch
finally
{
try{ bais.close(); } catch( Exception e ){}
try{ ois.close(); } catch( Exception e ){}
} // end finally
return obj;
}