|Perl: the Markov chain saw|
Compressing and Encrypting files on Windowsby hawtin (Prior)
|on Nov 01, 2004 at 09:07 UTC||Need Help??|
hawtin has asked for the
wisdom of the Perl Monks concerning the following question:
Fellow Monks: Every so often I come across a difficulty that I think is so common someone else must have a solution, but when I look I cannot find it. Here is one that I am struggling with at the moment.
I have a Perl application that stores sensitive data in an XML file. Which was perfect during development because it made it easy to see what was happening and try out various situations by editing the file. Now that I am moving toward deployment I want to provide "compress" and "encrypt" capabilities to the application user, something like this:
+---+ -->-Compress->-- -->-Encrypt->-| F | +-----+ / \ / | i | | App |->--? ->--? | l | +-----+ \ / \ | e | -->---->----->-- -->---->---->-| s | +---+
Which I thought I could implement like this (error handling removed for clarity):
Now if I was running on a *IX machine I could create an encryption process and pipe my (possibly) compressed data to it, but I'm on Windows and I can't get pipe and fork to do anything useful. The files are small enough that I could read them into memory, decrypt them, inflate them and then create an IO::Scalar for SAX, but that would need me to know more about the Compress::Zlib than I currently do.
I am running the ActiveState 5.6.1 on a Windows 2000 machine
This must be a common requirement and I am sure that the only reason the answer is not obvious is my lack of encryption experience. How have others done this?
Update: Of course I also want to do something similar when writing a file