in reply to Password Protect a Perl Script

> Is there any workaround to it?

often asked, always denied.

The perl-interpreter needs to read plain text, whichever en- and decryption you are doing, can be read by a man in the middle.

> I came across a situation where we are hard coding some critical information in a Perl script.

don't.

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^2: Password Protect a Perl Script
by hdb (Monsignor) on Oct 29, 2013 at 07:20 UTC

    One could compile one's own copy of Perl, modifying it in such a way that it decrypts encrypted scripts before doing its usual thing. With asymmetric encryption one could compile the private key into the executable. The command line perl --key would print the public key that one has to use to encrypt the scripts. Or even better, perl --encrypt script.pl would encrypt the script.

      Just make sure to deny loading any of the optree dumper modules, things that rewind __DATA__, etc. There are many avenues for attacking this setup. At best, it raises the bar a bit.

      --MidLifeXis