Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Obfuscating Perl (on purpose!)

by mcai7et2 (Initiate)
on Jan 05, 2001 at 17:15 UTC ( [id://50046]=perlquestion: print w/replies, xml ) Need Help??

mcai7et2 has asked for the wisdom of the Perl Monks concerning the following question:

A client of mine wants to be able to distribute Perl in a non readable manner. Is there a way of encrypting or encoding Perl code so it cannot be understood? The ideal situation would be to compile it to bytecode befre distribution, ala Java but is this possible and does it work in a cross platform, cross version (ie, compiled on 5.005, run on 5.6) manner?

If this is not an option are there any third party tools that would help?

Replies are listed 'Best First'.
Re: Obfuscating Perl (on purpose!)
by davorg (Chancellor) on Jan 05, 2001 at 17:40 UTC

    I have to ask just why your client wants to hide his Perl code. Surely this goes against the Open Source ethic that brought us Perl in the first place.

    If you do want to stop people from reusing your code, then security thru obscurity is no protection at all. As others have mentioned, just about any obfuscation technique can be broken by a determined attacker. You client's best bet would be to copyright the code and rigourously defend the copyright.

    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

      It is not for security, nor is it what I would do in their circumstance, but they are paying the bills so it is up to them.
        They may be left with the final decision, but it is your job to persuade them to do the *smart* thing, and by the way, java object code can be de-compiled back into sourcecode.

        "cRaZy is co01, but sometimes cRaZy is cRaZy".
                                                              - crazyinsomniac

Re: Obfuscating Perl (on purpose!)
by $code or die (Deacon) on Jan 05, 2001 at 17:32 UTC
    Another option is to have a look at perl2exe from IndigoStar. It will let you compile the perl interpreter, perl script and any modules it uses into one binary executeable.

    However, if you want to distribute it on Unix and Windows you will need to make seperate binary files with it. Also I have found that:
    It runs slower than running your plain text script the regular way
    Your files will not be less than around 800 regardless of how small your original script was

    It will do what you want it to do, and it's a nice tool to have and has it's place.

    Another tool is ActiveState's Dev Kit However this is Windows only. It allows you to do the same as above but without compiling the perl interpreter too - so the files are smaller and run faster, but require perl installed on the user's computer

    Having said all that, is it really necessary to make your code unreadable? Look at these PerlMonks links for more good advice: How can I hide the source for my Perl program?
    Protecting Perl Code
    Writing Highly Obfuscated Code in Perl by marko
Re: Obfuscating Perl (on purpose!)
by kilinrax (Deacon) on Jan 05, 2001 at 17:18 UTC
Re: Obfuscating Perl (on purpose!)
by ChOas (Curate) on Jan 05, 2001 at 17:21 UTC
Re: Obfuscating Perl (on purpose!)
by t0mas (Priest) on Jan 05, 2001 at 17:23 UTC
    You cold write a perlfilter (see perldoc perlfilter) to "hide" the code from your users. But any determined user will eventuallay crack your encrypted code if he/she puts enough effort into it.

    Open Source rules....

    /brother t0mas

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://50046]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-28 18:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found