java - How to serialize and deserialize a CipherInputStream object -


i having problem serializing cipherinputstream object. exception whenever try this, here snippet of code

public class crypto implements java.io.serializable {  public crypto(string filename) {  cipher cipher = cipher.getinstance("aes/ecb/pkcs5padding"); secretkeyspec secretkey = new secretkeyspec(key(), "aes"); cipher.init(cipher.encrypt_mode, secretkey); cipherinputstream cipt = new cipherinputstream(new fileinputstream(new file(filename)), cipher)  bytearrayoutputstream baos = new bytearrayoutputstream();    objectoutputstream obj = null;             try            {                 obj =   new objectoutputstream(baos);                 obj.writeobject(cipt);                 byte[] bv = baos.tobytearray();                 system.out.println(bv);             }            catch(exception b)            {            b.printstacktrace();            }                       {             obj.close();             baos.close();            }       }      } 

exception:

java.io.notserializableexception: javax.crypto.cipherinputstream. @ java.io.objectoutputstream.writeobject0(objectoutputstream.java:1180) 

can me this. aim convert cipherinputstream object bytes or bytearrays.

probably u wouldn't have implemented serialiazable marker class . suppose class 1 u need serialize , :

class implements serializable {    //class variables , methods   } 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

java - More than one row with the given identifier was found: 1, for class: com.model.Diagnosis -