Thanks for the reply Bill. You're of course correct - I should be dealing with the raw bytes and writing them out. I modified my code to use a FileOutputStream instead as you suggested, but to no avail... I get the same garbage on output. So, thinking that perhaps there was some issue with properties.getProperty("myEncryptedProperty"), I decided instead to:
A.)Read a line of text in from the FileReader and parse it it into
the property name and the current unencrypted property value
B.) Write out the property name as bytes
C.) Write the result of encrypting the property value.
So essentially I'm doing the encryption twice - once to set the property value in memory and the second to just write it out to the file. I was confident that this would work and I could go back and refactor the code later. It didn't! I get the same garbage... BUT if I just call properties.store() it works great. There's got to be something else more insidious at work here... It may have to do with this - from the Properties class javadoc...
Then every entry in this Properties table is written out, one per line. For each entry the key string is written, then an ASCII =, then the associated element string. Each character of the key and element strings is examined to see whether it should be rendered as an escape sequence. The ASCII characters \, tab, form feed, newline, and carriage return are written as \\, \t, \f \n, and \r, respectively. Characters less than \u0020 and characters greater than \u007E are written as \uxxxx for the appropriate hexadecimal value xxxx. For the key, all space characters are written with a preceding \ character. For the element, leading space characters, but not embedded or trailing space characters, are written with a preceding \ character. The key and element characters #, !, =, and : are written with a preceding backslash to ensure that they are properly loaded.
The result of the store call (which just uses a regular FileOutputStream:
e.g new BufferedOutputStream(new FileOutputStream(new File(path+".store")))
is a bunch of hexadecimal values, which CAN be decrypted properly
The result of the new code is still garbage e.g.
And here's the new code...
Thanks for continued help - I'm really confused about what the problem could with JUST writing out bytes...