Name Last Update
RSA Loading commit data...
test Loading commit data...
.gitignore Loading commit data...
README.md Loading commit data...
py2so.py Loading commit data...
requirments.txt Loading commit data...
verify.py Loading commit data...

鉴权与保护

0. 运行环境

  • python3

  • pip install -r requirements.txt

1. 鉴权(服务端): verify.py

  • 生成公私钥对

    python RSA/create_keys.py
    
    
  • 根据过期日期(必须)和MAC地址(可选, en0),通过私钥加密,生成认证文件

    • help text

      ❯ python RSA/encrypt.py -h
        usage: encrypt.py [-h] -d DATE [-m MAC]
      
        encrypt expire date & mac address with private key
      
        optional arguments:
          -h, --help            show this help message and exit
          -d DATE, --date DATE  expire date. eg: 2020-06-06
          -m MAC, --mac MAC     mac address
      
    • example

      python RSA/encrypt.py -d 2021-01-12 -m 38:f9:d3:2e:c0:f3
      
  • 项目使用

    • 拷贝以下文件至项目
      • 公钥:RSA/public.pem
      • 认证文件:RSA/certification.cert
      • 验证脚本:verify.py
    • 使用验证脚本鉴权

      from verify import verify
      is_valid = verify(path_to_public_key, path_to_cert)
      if is_valid:
          print('verify success')
      else:
          print('verify failed')
      
      

2. 保护源码:py2so.py

  • description: compile the .py to .so(Linux/Mac) or .pdy(Win)
  • help text

    ❯ python py2so.py -h
    usage: py2so.py [-h] -i INPUT [-o OUTPUT] [-e EXCLUDE]
    
    compile the .py to .so(Linux/Mac) or .pdy(Win)
    
    optional arguments:
      -h, --help            show this help message and exit
      -i INPUT, --input INPUT
                            the directory(file) path of your project
      -o OUTPUT, --output OUTPUT
                            the directory path of compiled file
      -e EXCLUDE, --exclude EXCLUDE
                            exclude file. eg: ignore/ignore.py,main.py,ignore
    
  • example

    python py2so.py -i test -e test,main.py