Answer the question
In order to leave comments, you need to log in
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
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
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.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question