Skip to main content

Advanced encryption protecting your python codebase.

Project description

SOURCEdefender - advanced encryption protecting your Python codebase


python downloads downloads

SOURCEdefender can protect your plaintext Python source code with AES 256-bit Encryption. There is no impact on the performance of your running application as the decryption process takes place during the import of your module or when loading your script on the command-line. Encrypted code won't run any slower once loaded from a .pye file compared to loading from a .py or .pyc file.

As we hook directly into the import process there are no cross platform or Python version compatibility issues. Encrypted code will run on the ANY target environment we support. Obviously your code needs to be written with the target platform in mind, we can't automagically make sys.getwindowsversion() work on Linux.

Features

  • Code encrypted with AES 256-bit encryption.
  • Encrypted code will run on ANY supported environment.
  • Enforced expire time on encrypted code (optional).

Supported Environments

Architecture Operating System Python 3.6 Python 3.7 Python 3.8 Python 3.9
x86_64 Windows Y Y Y Y
x86_64 Linux Y Y Y Y
x86_64 macOS Y Y Y Y
ARMv6 Linux Y Y Y Y
ARMv7 Linux Y Y Y Y

Usage

You can distribute the sourcedefender module with any project, commercial or otherwise. However, the purchase of a license is required for the distribution of encrypted code that will be used in a commercial offering. You do not need to purchase a subscription for use in a Personal or a FOSS project. However, we would greatly appreciate that you document the usage of SOURCEdefender on your website, documentation, and in your source code. Please link back to this page where you can.

How do I protect my Python source code?

Let's have a look at an example of the encryption process:

$ cat /home/ubuntu/helloworld.py
print("Hello World!")

This is a very basic example and produces the following output:

$ python3 /home/ubuntu/helloworld.py
Hello World!

We do not want anyone to get at our source code and we also don't want anyone to run this code after 1 day. When we encrypt the file we can enforce an expire time of 1 day from now with the --ttl option as follows:

$ sourcedefender encrypt --ttl=1d /home/ubuntu/helloworld.py
SOURCEdefender v6.0.21

Processing:

/home/ubuntu/helloworld.py

Now the file is encrypted, its contents are as follows:

$ cat /home/ubuntu/helloworld.pye
-----BEGIN SOURCEDEFENDER FILE -----
Version : 6.0.21

OVM1Jkp9MStTVG5DdlN2T0YzT2J8KSn+ostdVSiPu775++EzSxFw+kODnCo/6dNWjAgwqg+3hjsw
Ulo3akQyNjU2KUQ0bl87MjBgdkV65aVanyYZArQPV91zhm0QOwAOehbyyazX9HHJs8MDoZxi4U0W
EfX1y9gwzwlhVSExVkFBanhRQTtCRkZ3NjM4MTJGStGjnO4uqFQZOIEM36i2bdVmbzNlXiNUU0hG
YUI+SjQkekNMdUowNw==

------END SOURCEDEFENDER FILE ------

Once a file has been encrypted, its extension is changed .py to .pye, this is so the module knows its encrypted and can process it accordingly during import. All you need to remember is to inlcude sourcedefender as a dependency while packaging your project and import the sourcedefender module before you attempt to use your encrypted code.

Can I still run Python from the command-line?

Yes, you can still run scripts from the command-line, but you need to run the sourcedefender library module, and include your encrypted file name as the first argument:

$ python3 -m sourcedefender /home/ubuntu/helloworld.pye
Hello World!
$

Or access the module via the usual import system:

$ cd /home/ubuntu
$ ls
helloworld.pye
$ python3
>>>
>>> import sourcedefender
>>> import helloworld
Hello World!
>>> exit()
$

Integrating encrypted code with PyInstaller

PyInstaller scans your code for import statements so it knows what packages to freeze. This scanning is not possible inside encrypted code so you need to tell PyInstaller to include your encrypted files. For this example, we have the following project structure:

pyexe.py
lib
├── fibonacci.pye
└── fib.pye

In our executable script "pyexe.py" we have the following code:

$ cat pyexe.py
import sourcedefender
import fib

To ensure that PyInstaller includes our encrypted files, we need to tell it where they are with the --add-binary option. So, for the above project, we could use this command:

$ pyinstaller --onefile --add-binary lib:. pyexe.py

If you have imports that are not in your lib folder or you are using modules installed via pip and then imported inside your encrypted codebase then the pyinstaller won't be able to detect these. To get round this, you can use the '--hidden-import' option to include them in your final build such as this:

$ pyinstaller --onefile --add-binary lib:. --hidden-import tgcrypto --hidden-import msgpack 

Enterprise Subscription & Support

To create encrypted code for distribution in a commercial offering we require you to have an active subscription in place. The subscription is a rolling contract and gives you permission to create encrypted code for distribution and gain access to priority email support. Should you decide to cancel your subscription this action will revoke your permission to create encrypted code. Upon cancellation of your subscription you would be free to distribute any previously encrypted code, but you would not be able to make changes to existing files or create new ones for deploying a new feature, a bug fix, or a hot-patch.

Extra Enterprise Only Features

Enterprise users can provide their own encryption/decryption salt to ensure that nobody but the licensed user can run the code. This salt setting is required to be the same for encrypting and decrypting code to load and run in. If you are an enterprise subscriber please contact us regarding the activation of this feature.

Subscription Plans

  • Monthly Subscription: £50.
  • Annual Subscription (Saving 20%!): £500.

* All prices exclude VAT charged at 20%. VAT may be subject to change depending on your country of residence.

The subscription is valid for your whole organisation and not for a set person or machine. Once you subscribe there will be a record of your purchase on our system so we can validate your usage permissions.

Payment Options

The above links on this page take you to PayPal to manage the payment process.

Legal

Copyright (c) 2018-2020 SOURCEdefender. All rights reserved.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. REVERSE ENGINEERING IS STRICTLY PROHIBITED.

Company Details

SOURCEdefender is operated by RS474 Limited, a company registered in the United Kingdom.

  • Company Registration No: 12865773
  • VAT Registration No: GB357943163.

The goods and services you order through this site will be purchased from RS474 Limited.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sourcedefender, version 6.0.21
Filename, size File type Python version Upload date Hashes
Filename, size sourcedefender-6.0.21.tar.gz (3.1 MB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page