I
I
Ivan Karabadzhak2012-01-15 13:58:11
Java
Ivan Karabadzhak, 2012-01-15 13:58:11

Need to encrypt a Java program settings file?

I need to encrypt a java program settings file. A complex algorithm is not needed. Advise how this can be done quickly and without unnecessary gestures.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rafael Osipov, 2012-01-15
@Rafael

Offhand like this:
1. Create a child for ByteArrayOutputStream and overload the write(byte[] b, int off, int len) method to run the written byte array through XOR
2. Create a child for ByteArrayInputStream and overload the read(byte[] b, int method off, int len) to run a readable array of bytes through XOR
3. To work with the settings, we use the Properties class and its methods: storeToXML(OutputStream os, String comment) to write the settings to a file, and loadFromXML(InputStream in) to read the settings.
As parameters to these methods, pass instances of the stream classes created in steps 1 and 2

M
Monnoroch, 2012-01-15
@Monnoroch

And in my opinion, the coolest thing is not to encrypt anything, but just cram the left settings, and for the real ones use the “wrong” values: swap true and false and so on.
The upside is that only you will know that the settings are encrypted. And you don’t need to overload a ton of classes, just write a value converter method.

R
rPman, 2012-01-15
@rPman

Pack it, using java it is very simple ... and to make it completely non-trivial, add fixed-length random garbage to the beginning of the file before saving. Delov then for the extra 3 lines.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question