Merge branch 'master' of gitlab.situdata.com:zhouweiqi/encryption_script
Showing
1 changed file
with
10 additions
and
5 deletions
| 1 | ## 鉴权与保护 | 1 | ## 鉴权与保护 |
| 2 | ### 0. 运行环境 | 2 | ### 0. 运行环境 |
| 3 | |||
| 3 | - python3 | 4 | - python3 |
| 5 | |||
| 4 | - pip install -r requirements.txt | 6 | - pip install -r requirements.txt |
| 5 | 7 | ||
| 6 | ### 1. 鉴权(服务端): verify.py | 8 | ### 1. 鉴权(服务端): verify.py |
| 9 | |||
| 7 | - 生成公私钥对 | 10 | - 生成公私钥对 |
| 8 | ``` | 11 | ``` |
| 9 | python RSA/create_keys.py | 12 | python RSA/create_keys.py |
| 13 | |||
| 10 | ``` | 14 | ``` |
| 11 | - 根据过期日期(必须)和MAC地址(可选, en0),通过私钥加密,生成认证文件 | 15 | - 根据过期日期(必须)和MAC地址(可选, en0),通过私钥加密,生成认证文件 |
| 16 | |||
| 12 | - help text | 17 | - help text |
| 13 | ``` | 18 | ``` |
| 14 | ❯ python RSA/encrypt.py -h | 19 | ❯ python RSA/encrypt.py -h |
| ... | @@ -25,12 +30,13 @@ | ... | @@ -25,12 +30,13 @@ |
| 25 | ``` | 30 | ``` |
| 26 | python RSA/encrypt.py -d 2021-01-12 -m 38:f9:d3:2e:c0:f3 | 31 | python RSA/encrypt.py -d 2021-01-12 -m 38:f9:d3:2e:c0:f3 |
| 27 | ``` | 32 | ``` |
| 33 | |||
| 28 | - 项目使用 | 34 | - 项目使用 |
| 29 | - 拷贝以下文件至项目 | 35 | - 拷贝以下文件至项目 |
| 30 | - 公钥:RSA/public.pem | 36 | - 公钥:RSA/public.pem |
| 31 | - 认证文件:RSA/certification.cert | 37 | - 认证文件:RSA/certification.cert |
| 32 | - 验证脚本:verify.py | 38 | - 验证脚本:verify.py |
| 33 | - 使用验证脚本鉴权 | 39 | - 使用验证脚本鉴权(pip install pycryptdome getmac) |
| 34 | ``` | 40 | ``` |
| 35 | from verify import verify | 41 | from verify import verify |
| 36 | is_valid = verify(path_to_public_key, path_to_cert) | 42 | is_valid = verify(path_to_public_key, path_to_cert) |
| ... | @@ -38,13 +44,12 @@ | ... | @@ -38,13 +44,12 @@ |
| 38 | print('verify success') | 44 | print('verify success') |
| 39 | else: | 45 | else: |
| 40 | print('verify failed') | 46 | print('verify failed') |
| 47 | |||
| 41 | ``` | 48 | ``` |
| 42 | 49 | ||
| 43 | ### 2. 保护源码:py2so.py | 50 | ### 2. 保护源码:py2so.py |
| 44 | - description | 51 | |
| 45 | ```angular2html | 52 | - description: compile the .py to .so(Linux/Mac) or .pdy(Win) |
| 46 | compile the .py to .so(Linux/Mac) or .pdy(Win) | ||
| 47 | ``` | ||
| 48 | - help text | 53 | - help text |
| 49 | ``` | 54 | ``` |
| 50 | ❯ python py2so.py -h | 55 | ❯ python py2so.py -h | ... | ... |
-
Please register or sign in to post a comment