Is there an easy way to encrypt a java object?

前端 未结 7 1382
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-06 18:14

I\'d like to store a serialized object to a file however I\'d like to make it encrypted. It doesn\'t need to be really strong encryption. I just want something easy (preferably

相关标签:
7条回答
  • 2021-02-06 18:48

    Cant you just use any encryption library at all? Your basic code would be

    Object o=...;
    String s= new String();
    ObjectOutputStream out = new ObjectOutputStream(StringStream(s));
    out.writeObject(o);
    

    And then you just pass s into any encryption system you want.

    Edit: I forgot that StringStream is a C++ thing, not a Java one. But you can basically do the same thing, take a look here.

    0 讨论(0)
提交回复
热议问题