This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Streaming out de-encrypted data  RSS feed

 
Sara Tracy
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have 2 classes "parsing.java" and "enc.java". "parsing.java" parses an xml file "INFO.xml", to get a few attribute values. I'm using SAX parsing.

However, "INFO.xml" is encrypted (password based encryption), and needs to be de-encrypted before it can be parsed. So "parsing.java" calls "enc.java" which de-encrypts the xml file, and creates the "readable xml file" say "rINFO.xml". Then the program reads the xml file.

parsing.java


enc.java


You should have noticed that I'm creating a new file "rINFO.xml" and sending the de-encrypted data to that file. However, I would like to stream out the de-encrypted contents using output stream to "parsing.java", and do not want to save it as a file, because the whole purpose of encryption is lost otherwise.

1)Is there a way of having the de-encrytped xml file in memory and then parsing that ?
2) or streaming the de-encrypted contents to "parsing.java", where I can use

instead of ?

Any help appreciated. Thanks!
Sara

[ June 08, 2006: Message edited by: Sara James ]
[ June 08, 2006: Message edited by: Sara James ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could have the decFile method return the unencrypted byte array:

public byte[] decFile (String inputFile, String passphrase)

and then do something like:

reader.parse(new InputSource(new ByteArrayInputStream(f.decFile(...))));
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look up PipedOutputStream and PipedInputStream. Requires another thread.
 
Sara Tracy
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies Ulf and Stan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!