Esteemed Monks,

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:
if ($cv->{decrypt} =~ /y/i || ! -T $workFile || $workFile =~ /.pgp$/i || $workFile =~ /.gpg$/i) { my $decError = handleDecryption ($workFile); }
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.

TIA
vek.

In reply to File Encryption by vek

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.