On Tue, Feb 12, 2013 at 03:18:51PM -0800, John SJ Anderson wrote:
> 
> On Feb 12, 2013, at 3:05 PM, Kevin Walzer <k...@codebykevin.com> wrote:
> 
> > Does Perl have the equivalent of Python bytecode files, i.e. pyc,
> > that are obfuscated? If not, the OP's options may be limited.
> 
> No such critter in Perl.

Whilst that's true to a first, second and maybe even a third
approximation, it's perhaps not absolutely correct:

$ echo 'sub X { print 42 } 1' > X.pm
$ perl5.8.9 -MX -eX
42
$ perl5.8.9 -MO=Bytecode,-H -MX -e1 > XX.pmc
-e syntax OK
$ perl5.8.9 -MXX -eX
42
$ od -x XX.pmc
0000000 2123 2f20 7375 2f72 6f6c 6163 2f6c 6b70
0000020 2f67 6570 6c72 642f 6665 7561 746c 702f
0000040 7265 2d6c 2e35 2e38 2f39 6962 2f6e 6570
0000060 6c72 2e35 2e38 0a39 7375 2065 7942 6574
0000100 6f4c 6461 7265 3020 302e 3b36 500a 424c
0000120 7843 3638 365f 2d34 696c 756e 0078 2e30
0000140 3630 0800 0000 0800 0000 0c00 5938 0161
0000160 0000 0000 0000 6400 650d 0c40 5760 6d50
...
0001440 0000 0939 0000 3b00 0010 7e3a 0003 8900
0001460 000e 0000 0000
0001465


But, be that as it may, even this won't stop someone who knows what they
are doing being able to recover your source code, after a fashion.

In practice, it's all about degree.  Given that someone can run your
code locally, and that if they have sufficient time and skill they will
be able to reverse engineer your code to a greater or lesser extent
(which is true for all programs in all languages), often you just want to
hide your code from a curious observer, or to make it not worth
someone's while to put in that effort.

Modules such as Acme::Bleach have already been mentioned.  One approach
I have taken in the past is to embed perl inside a C program.  I have
encrypted the Perl source and added that as data in the C program.  The
C program decrypts the source and calls the embedded perl to execute it.
You also need to do something clever so that "use" and friends look at
the text in the C program first.  Then you distribute the executable.
That's probably more than sufficient for most purposes.

It's probably also more than sufficient for this list.

-- 
Paul Johnson - p...@pjcj.net
http://www.pjcj.net

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to