Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • Will you give me a hint for the decrypting part? Do I use the OutputStream as a writer then, or is it reading the encoded part? Commented Jul 12, 2017 at 19:42
  • @MalteS assuming you've written the encrypted data in a file, the code for decryption is exactly the same, except that you need to init your cipher in decrypt mode. Commented Jul 13, 2017 at 8:12
  • So I save it as a new file, I guess? Or is it better to override it? Commented Jul 13, 2017 at 9:15
  • You can use a pair of PipedOutputStream (and PipiedInputStream) to plug the encrypted outputStream to the deciphering inputStream if you want to decrypt right away. I understand you just want to exercise a bit but there is really no meaning to encrypt and decrypt a file in a row. Encryption is pretty much always done for storage or communication. You can plug the OutputStream to a file or to a websocket / servlet and that will cover most of the use for encryption. Commented Jul 13, 2017 at 9:31
  • I see it is not very senseful. So to save the encrypted file seperatly can I just write the string line; to a file because it is printing it correctly? Commented Jul 13, 2017 at 10:25