Hello Monks,

I found this cool little script on Usenet that encrypts Perl code. It works really well, as I tested it out on several scripts. My question... Is encrypted code such as this script produces portable, or are there any dependency issues?

Here is the script that does the encryption...

#! /usr/bin/perl -w # Copyright (c) 1998 Greg Bacon. All Rights Reserved. # This program is free software. You may distribute it or modify # it (perhaps both) under the terms of the Artistic License that # comes with the Perl Kit. use strict; use integer; foreach my $file (@ARGV) { unless (open FILE, $file) { warn "$0: failed open $file: $!\n"; next; } my $key = int rand 256; my $out = <<EOTop; #! /usr/bin/perl my \$prog = ''; { my \$key = $key; local \$/; \$prog = pack "c*", map { \$_ ^= \$key } unpack "c*", <DATA>; } eval \$prog; __END__ EOTop while (<FILE>) { $out .= pack "c*", map { $_ ^= $key } unpack "c*", $_; } close FILE; unless (open FILE, ">$file") { warn "$0: failed open >$file: $!\n"; next; } print FILE $out; close FILE;; }

In reply to encryption portability? by Anonymous Monk

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.