pylicenser


Namepylicenser JSON
Version 0.0.14 PyPI version JSON
download
home_pageNone
Summary代码混淆
upload_time2024-09-13 04:30:21
maintainerNone
docs_urlNone
authordage.lx
requires_python<4,>=3.6
licenseNone
keywords encrypt pylicenser
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pylicenser
提供了2种加密的方式:
1. 基于[sourcedefender](https://pypi.org/project/sourcedefender/)的原理自己加以实现的,更好的兼容了目录级别的代码加密。
2. 使用Cython进行代码封装,也支持了目录级别的文件加密。  

此外,Pylicenser还支持运行时的过期校验——即设置ttl,服务启动后,Pylicenser会在其运行过程中时检测失效时间。

## 安装

```shell script
pip install pylicenser
```

## 1. 使用encrypt方式加密
```text
usage: pylicenser encrypt [-h] [--ttl TTL] [--dist DIST] str [str ...]

positional arguments:
  str          待加密的文件或文件夹

optional arguments:
  -h, --help   帮助信息
  --ttl TTL    有效日期,默认:0,单位:seconds。示例: 1s、2d、3m、4h (default: 0)
  --dist DIST  输出目录,默认当前dist目录 (default: ./dist)
  --verbose   是否打印日志 (default: False)
```

### 运行加密代码
该种方式支持使用pylicenser run运行加密脚本,但是不支持原生的```python -m script```,如需使用该种方式请采用撰写脚本引用的方式进行。

#### pylicenser run
```text
usage: pylicenser run [-h] script ...

positional arguments:
  script      py脚本文件
  args        脚本需要的参数

optional arguments:
  -h, --help  帮助信息
  --verbose   是否打印日志 (default: False)
```

### 脚本加载引用加密后pye文件
```python
# 需要先引入,用于识别pye文件
import pylicenser
from package.module_file import func # module_file为加密后的pye文件
if __name__ == '__main__':
    print(func(1, 4, 'x'))
```

##  2. 使用Cython方式加密
采用该方式需要预先安装Cython,安装方式如下:
```shell script
pip install Cython
```
使用方式如下:
```text
usage: pylicenser cython [--dist DIST] [-h] str [str ...]

positional arguments:
  str          待编译的代码文件或文件夹

optional arguments:
  --dist DIST  输出目录,默认当前dist目录 (default: ./dist)
  -h, --help   帮助信息
  --verbose   是否打印日志 (default: False)
```

**Cython加密后,不影响代码原有使用方式,即原来脚本怎么运行,加密后还是怎么运行。**  
**相较于第一种加密,Cython加密具有平台依赖性,即在darwin上加密的代码在win或者linux下不一定能运行。**


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pylicenser",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.6",
    "maintainer_email": null,
    "keywords": "encrypt, pylicenser",
    "author": "dage.lx",
    "author_email": "dage.lx@mybank.cn",
    "download_url": null,
    "platform": null,
    "description": "# Pylicenser\n\u63d0\u4f9b\u4e862\u79cd\u52a0\u5bc6\u7684\u65b9\u5f0f\uff1a\n1. \u57fa\u4e8e[sourcedefender](https://pypi.org/project/sourcedefender/)\u7684\u539f\u7406\u81ea\u5df1\u52a0\u4ee5\u5b9e\u73b0\u7684\uff0c\u66f4\u597d\u7684\u517c\u5bb9\u4e86\u76ee\u5f55\u7ea7\u522b\u7684\u4ee3\u7801\u52a0\u5bc6\u3002\n2. \u4f7f\u7528Cython\u8fdb\u884c\u4ee3\u7801\u5c01\u88c5\uff0c\u4e5f\u652f\u6301\u4e86\u76ee\u5f55\u7ea7\u522b\u7684\u6587\u4ef6\u52a0\u5bc6\u3002  \n\n\u6b64\u5916\uff0cPylicenser\u8fd8\u652f\u6301\u8fd0\u884c\u65f6\u7684\u8fc7\u671f\u6821\u9a8c\u2014\u2014\u5373\u8bbe\u7f6ettl\uff0c\u670d\u52a1\u542f\u52a8\u540e\uff0cPylicenser\u4f1a\u5728\u5176\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u65f6\u68c0\u6d4b\u5931\u6548\u65f6\u95f4\u3002\n\n## \u5b89\u88c5\n\n```shell script\npip install pylicenser\n```\n\n## 1. \u4f7f\u7528encrypt\u65b9\u5f0f\u52a0\u5bc6\n```text\nusage: pylicenser encrypt [-h] [--ttl TTL] [--dist DIST] str [str ...]\n\npositional arguments:\n  str          \u5f85\u52a0\u5bc6\u7684\u6587\u4ef6\u6216\u6587\u4ef6\u5939\n\noptional arguments:\n  -h, --help   \u5e2e\u52a9\u4fe1\u606f\n  --ttl TTL    \u6709\u6548\u65e5\u671f\uff0c\u9ed8\u8ba4\uff1a0\uff0c\u5355\u4f4d\uff1aseconds\u3002\u793a\u4f8b\uff1a 1s\u30012d\u30013m\u30014h (default: 0)\n  --dist DIST  \u8f93\u51fa\u76ee\u5f55\uff0c\u9ed8\u8ba4\u5f53\u524ddist\u76ee\u5f55 (default: ./dist)\n  --verbose   \u662f\u5426\u6253\u5370\u65e5\u5fd7 (default: False)\n```\n\n### \u8fd0\u884c\u52a0\u5bc6\u4ee3\u7801\n\u8be5\u79cd\u65b9\u5f0f\u652f\u6301\u4f7f\u7528pylicenser run\u8fd0\u884c\u52a0\u5bc6\u811a\u672c\uff0c\u4f46\u662f\u4e0d\u652f\u6301\u539f\u751f\u7684```python -m script```\uff0c\u5982\u9700\u4f7f\u7528\u8be5\u79cd\u65b9\u5f0f\u8bf7\u91c7\u7528\u64b0\u5199\u811a\u672c\u5f15\u7528\u7684\u65b9\u5f0f\u8fdb\u884c\u3002\n\n#### pylicenser run\n```text\nusage: pylicenser run [-h] script ...\n\npositional arguments:\n  script      py\u811a\u672c\u6587\u4ef6\n  args        \u811a\u672c\u9700\u8981\u7684\u53c2\u6570\n\noptional arguments:\n  -h, --help  \u5e2e\u52a9\u4fe1\u606f\n  --verbose   \u662f\u5426\u6253\u5370\u65e5\u5fd7 (default: False)\n```\n\n### \u811a\u672c\u52a0\u8f7d\u5f15\u7528\u52a0\u5bc6\u540epye\u6587\u4ef6\n```python\n# \u9700\u8981\u5148\u5f15\u5165\uff0c\u7528\u4e8e\u8bc6\u522bpye\u6587\u4ef6\nimport pylicenser\nfrom package.module_file import func # module_file\u4e3a\u52a0\u5bc6\u540e\u7684pye\u6587\u4ef6\nif __name__ == '__main__':\n    print(func(1, 4, 'x'))\n```\n\n##  2. \u4f7f\u7528Cython\u65b9\u5f0f\u52a0\u5bc6\n\u91c7\u7528\u8be5\u65b9\u5f0f\u9700\u8981\u9884\u5148\u5b89\u88c5Cython\uff0c\u5b89\u88c5\u65b9\u5f0f\u5982\u4e0b\uff1a\n```shell script\npip install Cython\n```\n\u4f7f\u7528\u65b9\u5f0f\u5982\u4e0b\uff1a\n```text\nusage: pylicenser cython [--dist DIST] [-h] str [str ...]\n\npositional arguments:\n  str          \u5f85\u7f16\u8bd1\u7684\u4ee3\u7801\u6587\u4ef6\u6216\u6587\u4ef6\u5939\n\noptional arguments:\n  --dist DIST  \u8f93\u51fa\u76ee\u5f55\uff0c\u9ed8\u8ba4\u5f53\u524ddist\u76ee\u5f55 (default: ./dist)\n  -h, --help   \u5e2e\u52a9\u4fe1\u606f\n  --verbose   \u662f\u5426\u6253\u5370\u65e5\u5fd7 (default: False)\n```\n\n**Cython\u52a0\u5bc6\u540e\uff0c\u4e0d\u5f71\u54cd\u4ee3\u7801\u539f\u6709\u4f7f\u7528\u65b9\u5f0f\uff0c\u5373\u539f\u6765\u811a\u672c\u600e\u4e48\u8fd0\u884c\uff0c\u52a0\u5bc6\u540e\u8fd8\u662f\u600e\u4e48\u8fd0\u884c\u3002**  \n**\u76f8\u8f83\u4e8e\u7b2c\u4e00\u79cd\u52a0\u5bc6\uff0cCython\u52a0\u5bc6\u5177\u6709\u5e73\u53f0\u4f9d\u8d56\u6027\uff0c\u5373\u5728darwin\u4e0a\u52a0\u5bc6\u7684\u4ee3\u7801\u5728win\u6216\u8005linux\u4e0b\u4e0d\u4e00\u5b9a\u80fd\u8fd0\u884c\u3002**\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "\u4ee3\u7801\u6df7\u6dc6",
    "version": "0.0.14",
    "project_urls": {
        "Source": "https://gitlab.bailian-ai.com/ai_algo/pylicenser"
    },
    "split_keywords": [
        "encrypt",
        " pylicenser"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c4aaac7e881a7154238dacd58d4ea2ff62c964982ce508f315b1a35692f9c2b9",
                "md5": "3aba4eaf8e0ce423eb10951f603ee78f",
                "sha256": "d5500e54cf7ebf0b85cdd5e0fc5cb8a6687a4e554c30b0ff9b7747b25786aa3e"
            },
            "downloads": -1,
            "filename": "pylicenser-0.0.14-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "has_sig": false,
            "md5_digest": "3aba4eaf8e0ce423eb10951f603ee78f",
            "packagetype": "bdist_wheel",
            "python_version": "cp36",
            "requires_python": "<4,>=3.6",
            "size": 1690182,
            "upload_time": "2024-09-13T04:30:21",
            "upload_time_iso_8601": "2024-09-13T04:30:21.984676Z",
            "url": "https://files.pythonhosted.org/packages/c4/aa/ac7e881a7154238dacd58d4ea2ff62c964982ce508f315b1a35692f9c2b9/pylicenser-0.0.14-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af1f5b5109aa069d433e9578af5fa146454934b864dfd07e9a297451e905e2df",
                "md5": "7561b5f1a7d9fa2bca1d764bb2c47518",
                "sha256": "4aea29e4b4582ed59b8226fe58b46831a741cf1d1ec343bf39468f70241fefc8"
            },
            "downloads": -1,
            "filename": "pylicenser-0.0.14-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "has_sig": false,
            "md5_digest": "7561b5f1a7d9fa2bca1d764bb2c47518",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": "<4,>=3.6",
            "size": 1830334,
            "upload_time": "2024-09-13T04:30:25",
            "upload_time_iso_8601": "2024-09-13T04:30:25.169514Z",
            "url": "https://files.pythonhosted.org/packages/af/1f/5b5109aa069d433e9578af5fa146454934b864dfd07e9a297451e905e2df/pylicenser-0.0.14-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d1a2b497494e27ac207e304de81afb3733506194d89a24c4cebd3ddd30e39ebe",
                "md5": "fb61a9c5db1024c7bdfa03c9875b826a",
                "sha256": "552759b06c2f3d76e02d2cddad2503697ff53bffb208a1c9566b2f853d31dea9"
            },
            "downloads": -1,
            "filename": "pylicenser-0.0.14-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "has_sig": false,
            "md5_digest": "fb61a9c5db1024c7bdfa03c9875b826a",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": "<4,>=3.6",
            "size": 1924434,
            "upload_time": "2024-09-13T04:30:28",
            "upload_time_iso_8601": "2024-09-13T04:30:28.512605Z",
            "url": "https://files.pythonhosted.org/packages/d1/a2/b497494e27ac207e304de81afb3733506194d89a24c4cebd3ddd30e39ebe/pylicenser-0.0.14-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "173a08af1dc4339e56c85a63e9d7346192f0516817f834f9921a27997b7b30ca",
                "md5": "6118735e40027b233428f5306971b071",
                "sha256": "b406ce4e2920ee20bea56256d68974e8df79241440426ee2280bf28dac7ed035"
            },
            "downloads": -1,
            "filename": "pylicenser-0.0.14-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "has_sig": false,
            "md5_digest": "6118735e40027b233428f5306971b071",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": "<4,>=3.6",
            "size": 1757476,
            "upload_time": "2024-09-13T04:30:31",
            "upload_time_iso_8601": "2024-09-13T04:30:31.086318Z",
            "url": "https://files.pythonhosted.org/packages/17/3a/08af1dc4339e56c85a63e9d7346192f0516817f834f9921a27997b7b30ca/pylicenser-0.0.14-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-13 04:30:21",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pylicenser"
}
        
Elapsed time: 3.72777s