Module::Crypt - Encrypt your Perl code and compile it into XS


 use Module::Crypt;
 #Êfor a single file:
    file => '',
    install_base => '/path/to/my/lib'
 # for multiple files:
    files => ['', ''],
    install_base => '/path/to/my/lib'
 # for a directory:
    files => '/path/to/source/dir',
    install_base => '/path/to/my/lib'


Module::Crypt encrypts your pure-Perl modules and then compiles them into a XS module. It lets you distribute binary versions without disclosing code, although please note that we should better call this an obfuscation, as Perl is still internally working with your original code. While this isn't 100% safe, it makes code retrival much harder than any other known Perl obfuscation method.



This function does the actual encryption and compilation. It is supposed to be called from a Makefile-like script that you'll create inside your development directory. The 4 lines you see in each of the examples above are sufficient to build (and rebuild) the modules.


This contains the path of your source module. It can be a relative filename too, if you're launching your CryptModule() from the same directory.


If you want to encrypt and compile multiple modules, you can pass an arrayref to the files parameter with the paths/filenames listed. If you pass a string instead of of an arrayref, it will be interpreted as a directory path so that Module::Crypt will scan it and automatically add any .pm file to the modules list.


(Optional) This parameter contains the destination of the compiled modules. If not specified, it defaults to a directory named "output" inside the current working directory.


  • There could be some malloc() errors when encrypting long scripts. It should be very easy to fix this (the cause is bad way to calculate allocation needs).


Latest versions can be downloaded from CPAN. You are very welcome to write mail to the author ( with your contributions, comments, suggestions, bug reports or complaints.


Alessandro Ranellucci <>


Copyright (c) 2005 Alessandro Ranellucci. Module::Crypt is free software, you may redistribute it and/or modify it under the same terms as Perl itself.


This is highly experimental code. Use it AT YOUR OWN RISK. This software is provided by the copyright holders and contributors ``as is'' and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the regents or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 285:

Non-ASCII character seen before =encoding in '#Êfor'. Assuming ISO8859-1