Concepts

Pyarmor CLI

Pyarmor CLI is command line tool to generate the obfuscated scripts

digraph G { node [shape=box, style=rounded, target="_top"] package [label="Python package: pyarmor.cli\nPublished in the PyPI" href="https://pypi.org/project/pyarmor.cli/"] install [label="In build device installing command `pyarmor`\npip install pyarmor.cli"] pyarmor [label="Execute command `pyarmor` to do everyting"] package -> install -> pyarmor }

Pyarmor CLI Life Cycle

Components

digraph G { node [shape=box, style=rounded, target="_top"] subgraph C { cluster=true label="Sub-Commands" style="setlinewidth(0)" init [label="pyarmor init", href="commands.html#cmd-init"] env [label="pyarmor env", href="commands.html#cmd-env"] build [label="pyarmor build", href="commands.html#cmd-build"] } }

Functional Relationship

digraph G { node [shape=box, style=rounded, target="_top"] init [label="pyarmor init", href="commands.html#cmd-init"] env [label="pyarmor env", href="commands.html#cmd-env"] build [label="pyarmor build", href="commands.html#cmd-build"] project [label="Project", href="concepts.html#project"] miniscript [label="Mini Script", href="concepts.html#mini-script"] rftscript [label="RFT Script", href="concepts.html#rft-script"] license [shape=component, label="Pyarmor License", href="https://pyarmor.readthedocs.io/en/latest/licenses.html"] joint [shape=point] init -> project [label="Create"] env -> project [label="Configure"] project -> build [label="Scripts and options"] build -> miniscript [label="Generate"] joint -> rftscript [label="Generate"] build -> joint [arrowhead=none, tailport=se] license -> joint [label="Unlock RFT feature", arrowhead=none] }

Functional Relationship

Project

Project is set of scripts and options

digraph G { node [shape=box, style=rounded, target="_top"] rankdir="LR" subgraph C { cluster=true label="Project" scripts [label="Scripts", href="project.html"] modules [label="Modules", href="project.html"] package [label="Packages", href="project.html"] rftoptions [label="Refactor Options", shape=oval, href="project.html#rft-options"] } edge [style=invis] scripts -> modules -> package -> rftoptions }

Obfuscated Scripts

digraph G { node [shape=box, style=rounded, target="_top"] rankdir="LR" subgraph C { cluster=true label="Obfuscated Scripts" style="setlinewidth(0)" std [label="Std Script", href="https://pyarmor.readthedocs.io/en/latest/tutorial/getting-started.html"] rft [label="RFT Script", href="concepts.html#rft-script"] mini [label="Mini Script", href="concepts.html#mini-script"] } edge [style=invis] std -> rft -> mini }

Table-1. Comparison of Different Scripts

Script Type

Security [1]

Performance [2]

Need Extension [3]

Remark

Std Script

✫✫✫

✫✫✫

Yes

Could bind scripts to device or expired

Mini Script

✫✫✫✫

Yes

High execution speed, suitable for web services

RFT Script

✫✫✫✫

✫✫✫✫✫

No

Only rename most variables/classes/functions etc. in the original script

Notes

Mini Script

Mini Script consists of one common Python script and an extension pyarmor_mini.so

For example, there is one script like this

print('Hello')

The corresponding Mini Script would be

from pyarmor_mini import __pyarmor__
__pyarmor__(__name__, b'xxxx')

It’s one common Python script, but need import one extra module pyarmor_mini which could be installed by this way:

$ pip install pyarmor.mini

RFT Script

RFT Scripts is same as original Python scripts, only variables/classes/functions etc. are renamed

For example, there is one script like this

 1def plusinc(m, n=1):
 2        return m + n + 1
 3a = plusinc
 4b = a
 5n = b(1, n=2)
 6
 7def hello():
 8    return b(3, n=4)
 9
10print('result is', n + hello())

The corresponding RFT Script would be

1def pyarmor__3(pyarmor__1, pyarmor__2=1):
2    return pyarmor__1 + pyarmor__2 + 1
3pyarmor__4 = pyarmor__3
4pyarmor__5 = pyarmor__4
5pyarmor__2 = pyarmor__5(1, pyarmor__2=2)
6
7def pyarmor__6():
8    return pyarmor__5(3, pyarmor__2=4)
9print('result is', pyarmor__2 + pyarmor__6())