|Pathologically Eclectic Rubbish Lister|
File Encryptionby vek (Prior)
|on Dec 16, 2001 at 22:10 UTC||Need Help??|
vek has asked for the wisdom of the Perl Monks concerning the following question:
I went googling for this answer and came across a post to the perl-beginners list that is almost exactly the same dilemma I'm facing. Unfortunately, I didn't find an answer that helps me out. Bascically the question is 'how do you test to see if a file is encrypted?'
We receive files from many vendors on a daily basis. Each vendor has their own MySQL configuration table that our Application Support folks maintain - that way each time we bring a new vendor on board no programming is *usually* required. One of the columns in the table is called 'decrypt' - you either set this flag to 'Y' or 'N'. If the vendor supplies encrypted files, set this flag to 'Y' - the decryption routines will only be called if this 'flag' is set to 'Y'.
Obviously it's not safe to just rely on Application Support getting this right so I need my program to be smart enough to see if a file is encrypted even if the config table has 'N' in the 'decrypt' column.
Here's the code:
Can anyone suggest any other tests for encryption? Maybe the answer is not to test the file at all and just throw the file at GnuPG even if it's not encrypted - that's rather messy though and I'd rather not call the decryption routines if I don't have to.