I’m writing a little utility that will allow our config files to be encrypted, to keep curious developers from mucking around with settings they shouldn’t touch. My encrypt method starts with the following…
[CODE]CipherOutputStream cout = new CipherOutputStream(new BufferedOutputStream(out), enCipher);
DataInputStream din = new DataInputStream(new BufferedInputStream(in));
DataOutputStream dout = new DataOutputStream(cout);
This works beautifully, and I end up with a file full of encrypted text. However I’m running into a problem with the opposite code in my decrypt() method.
[CODE]CipherInputStream cin = new CipherInputStream(new BufferedInputStream(in), deCipher);
DataInputStream din = new DataInputStream(cin);
DataOutputStream dout = new DataOutputStream(new BufferedOutputStream(out));
in is an InputStream passed to the method representing the file being decrypted. Calling in.available() with my current test file shows 32 bytes in the stream. When I create cin though it seems as though the contents of in are not making it through to the CipherInputStream. Calling cin.available() returns 0 bytes. Naturally this makes it a little hard to read the stream ? Anyone ever run into something like this? I’ve run into the same problem when not using the BufferedInputStream. Is there some method I should be calling after constructing the stream, to initialize it or something? Could my deCipher object be to blame?