Security module for asterisk series.
Project description
asterisk-security
介绍
这个小项目最初是几年前写Django的项目,想在后端写个cookie的加密功能,后来就自己动手写了一个可以加密的函数。主要是个人工作的积累而已。随着后续开发的需求,将不断将更多的个人经验总结道这个开源项目。
项目交流与缺陷提交这里
软件架构
/
|-- asterisksecurity/
| |-- encryption.py
| | |-- AsteriskEncrypt
| |
| |-- error.py
| | |-- InvalidEncriptionKey
安装教程
pip install asterisk-security
使用说明
安装后在python代码中引入,实例化后调用
- 需要以key来实例化
AsteriskEncrypt
类 encrypt
方法可以将传参字符串进行加密并返回字符串decrypt
方法将已加密的字符串进行解密
例子:
from asterisksecurity.encryption import AsteriskEncrypt
def test_encrypt():
key = 'X7UJi2VdqcQlc3thv2dDPEn5y3yv3eTk35yyAhlKeAY1'
a = AsteriskEncrypt(key)
s = '你好世界!Hello World!'
s_enc = a.encrypt(s)
print(s_enc)
a_dec = a.decrypt(s_enc)
print(a_dec)
if __name__ == '__main__':
test_encrypt()
直接使用命令行
- 使用asencrypt命令
usage: asencrypt [-h] [-key K] [-txt T]
asterisk-security加密工具
options:
-h, --help show this help message and exit
-key K 加密密钥,长度不能超过22个字符,否则,进行左右11个字符截取,格式:[a-zA-Z0-9]+,不得包含特殊字符 encrypt key, length should not exceed 22 characters, otherwise, left and
right 11 characters will be intercepted, format: [a-zA-Z0-9]+, no special characters allowed
-txt T 需要加密的字符串 string to be encrypted```markdown
- 使用asdecrypt命令
usage: asdecrypt [-h] [-key K] [-txt T]
asterisk-security解密工具
options:
-h, --help show this help message and exit
-key K 解密密钥,长度不能超过22个字符,否则,进行左右11个字符截取,格式:[a-zA-Z0-9]+,不得包含特殊字符 decrypt key, length should not exceed 22 characters, otherwise, left and
right 11 characters will be intercepted, format: [a-zA-Z0-9]+, no special characters allowed
-txt T 需要解密的字符串 string to be decrypted
错误说明
- key字符串如果不符合格式要求,会抛出error
- 其他在解密过程中有任何error都不做处理。
参与贡献
- Fork 本仓库
- 新建 Feat_xxx 分支
- 提交代码
- 新建 Pull Request
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file asterisk_security-0.1.2.516.1645.tar.gz
.
File metadata
- Download URL: asterisk_security-0.1.2.516.1645.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbec9638d2e76cfce649edbdd290737a31d98440db259d8075db946f1d695c5d |
|
MD5 | a69862ecf54377602a1bf6fce2d98d84 |
|
BLAKE2b-256 | 7b7d19e229a91edcb57ed31435420ac2f7db5983c66528753226ef566df6822d |
File details
Details for the file asterisk_security-0.1.2.516.1645-py3-none-any.whl
.
File metadata
- Download URL: asterisk_security-0.1.2.516.1645-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ca97bbd7cf478b6bb05a9d575218c5db6440e967db239cbf6493fd73c481b5b |
|
MD5 | 8ac7b166c8136a4f59b231378bba3dd7 |
|
BLAKE2b-256 | aff04778a2d83de30d8f5d817d5d9397c2af648aa7c036f3286af7085d1cc68e |