asterisk-security


Nameasterisk-security JSON
Version 0.1.2.516.1645 PyPI version JSON
download
home_pageNone
SummarySecurity module for asterisk series.
upload_time2024-05-16 08:45:18
maintainerNone
docs_urlNone
authorShan,Tian
requires_python>=3.10.0
licenseApache License 2.0
keywords encrypt decrypt security asterisk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # asterisk-security

## 介绍

这个小项目最初是几年前写Django的项目,想在后端写个cookie的加密功能,后来就自己动手写了一个可以加密的函数。主要是个人工作的积累而已。随着后续开发的需求,将不断将更多的个人经验总结道这个开源项目。

项目交流与缺陷提交[这里](https://gitee.com/zhangxin_1/asterisk-security)

## 软件架构

```markdown
/
|-- asterisksecurity/
|   |-- encryption.py
|   |   |-- AsteriskEncrypt
|   |
|   |-- error.py
|   |   |-- InvalidEncriptionKey
```

## 安装教程

1. `pip install asterisk-security`

## 使用说明

### 安装后在python代码中引入,实例化后调用

1. 需要以key来实例化`AsteriskEncrypt`类
2. `encrypt`方法可以将传参字符串进行加密并返回字符串
3. `decrypt`方法将已加密的字符串进行解密

例子:

```python
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命令

```command-line
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命令
  
```command-line
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
```

## 错误说明

1. key字符串如果不符合格式要求,会抛出error
2. 其他在解密过程中有任何error都不做处理。

## 参与贡献

1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "asterisk-security",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10.0",
    "maintainer_email": null,
    "keywords": "encrypt, decrypt, security, asterisk",
    "author": "Shan,Tian",
    "author_email": "geoshan@163.com",
    "download_url": "https://files.pythonhosted.org/packages/7b/7d/19e229a91edcb57ed31435420ac2f7db5983c66528753226ef566df6822d/asterisk_security-0.1.2.516.1645.tar.gz",
    "platform": "Independent",
    "description": "# asterisk-security\n\n## \u4ecb\u7ecd\n\n\u8fd9\u4e2a\u5c0f\u9879\u76ee\u6700\u521d\u662f\u51e0\u5e74\u524d\u5199Django\u7684\u9879\u76ee\uff0c\u60f3\u5728\u540e\u7aef\u5199\u4e2acookie\u7684\u52a0\u5bc6\u529f\u80fd\uff0c\u540e\u6765\u5c31\u81ea\u5df1\u52a8\u624b\u5199\u4e86\u4e00\u4e2a\u53ef\u4ee5\u52a0\u5bc6\u7684\u51fd\u6570\u3002\u4e3b\u8981\u662f\u4e2a\u4eba\u5de5\u4f5c\u7684\u79ef\u7d2f\u800c\u5df2\u3002\u968f\u7740\u540e\u7eed\u5f00\u53d1\u7684\u9700\u6c42\uff0c\u5c06\u4e0d\u65ad\u5c06\u66f4\u591a\u7684\u4e2a\u4eba\u7ecf\u9a8c\u603b\u7ed3\u9053\u8fd9\u4e2a\u5f00\u6e90\u9879\u76ee\u3002\n\n\u9879\u76ee\u4ea4\u6d41\u4e0e\u7f3a\u9677\u63d0\u4ea4[\u8fd9\u91cc](https://gitee.com/zhangxin_1/asterisk-security)\n\n## \u8f6f\u4ef6\u67b6\u6784\n\n```markdown\n/\n|-- asterisksecurity/\n|   |-- encryption.py\n|   |   |-- AsteriskEncrypt\n|   |\n|   |-- error.py\n|   |   |-- InvalidEncriptionKey\n```\n\n## \u5b89\u88c5\u6559\u7a0b\n\n1. `pip install asterisk-security`\n\n## \u4f7f\u7528\u8bf4\u660e\n\n### \u5b89\u88c5\u540e\u5728python\u4ee3\u7801\u4e2d\u5f15\u5165\uff0c\u5b9e\u4f8b\u5316\u540e\u8c03\u7528\n\n1. \u9700\u8981\u4ee5key\u6765\u5b9e\u4f8b\u5316`AsteriskEncrypt`\u7c7b\n2. `encrypt`\u65b9\u6cd5\u53ef\u4ee5\u5c06\u4f20\u53c2\u5b57\u7b26\u4e32\u8fdb\u884c\u52a0\u5bc6\u5e76\u8fd4\u56de\u5b57\u7b26\u4e32\n3. `decrypt`\u65b9\u6cd5\u5c06\u5df2\u52a0\u5bc6\u7684\u5b57\u7b26\u4e32\u8fdb\u884c\u89e3\u5bc6\n\n\u4f8b\u5b50\uff1a\n\n```python\nfrom asterisksecurity.encryption import AsteriskEncrypt\n\ndef test_encrypt():\n    key = 'X7UJi2VdqcQlc3thv2dDPEn5y3yv3eTk35yyAhlKeAY1'\n    a = AsteriskEncrypt(key)\n    s = '\u4f60\u597d\u4e16\u754c\uff01Hello World!'\n    s_enc = a.encrypt(s)\n    print(s_enc)\n\n    a_dec = a.decrypt(s_enc)\n    print(a_dec)\n\nif __name__ == '__main__':\n    test_encrypt()\n\n```\n\n### \u76f4\u63a5\u4f7f\u7528\u547d\u4ee4\u884c\n\n* \u4f7f\u7528asencrypt\u547d\u4ee4\n\n```command-line\nusage: asencrypt [-h] [-key K] [-txt T]\n\nasterisk-security\u52a0\u5bc6\u5de5\u5177\n\noptions:\n  -h, --help  show this help message and exit\n  -key K      \u52a0\u5bc6\u5bc6\u94a5\uff0c\u957f\u5ea6\u4e0d\u80fd\u8d85\u8fc722\u4e2a\u5b57\u7b26\uff0c\u5426\u5219\uff0c\u8fdb\u884c\u5de6\u53f311\u4e2a\u5b57\u7b26\u622a\u53d6\uff0c\u683c\u5f0f\uff1a[a-zA-Z0-9]+\uff0c\u4e0d\u5f97\u5305\u542b\u7279\u6b8a\u5b57\u7b26 encrypt key, length should not exceed 22 characters, otherwise, left and\n              right 11 characters will be intercepted, format: [a-zA-Z0-9]+, no special characters allowed\n  -txt T      \u9700\u8981\u52a0\u5bc6\u7684\u5b57\u7b26\u4e32 string to be encrypted```markdown\n\n\n```\n\n* \u4f7f\u7528asdecrypt\u547d\u4ee4\n  \n```command-line\nusage: asdecrypt [-h] [-key K] [-txt T]\n\nasterisk-security\u89e3\u5bc6\u5de5\u5177\n\noptions:\n  -h, --help  show this help message and exit\n  -key K      \u89e3\u5bc6\u5bc6\u94a5\uff0c\u957f\u5ea6\u4e0d\u80fd\u8d85\u8fc722\u4e2a\u5b57\u7b26\uff0c\u5426\u5219\uff0c\u8fdb\u884c\u5de6\u53f311\u4e2a\u5b57\u7b26\u622a\u53d6\uff0c\u683c\u5f0f\uff1a[a-zA-Z0-9]+\uff0c\u4e0d\u5f97\u5305\u542b\u7279\u6b8a\u5b57\u7b26 decrypt key, length should not exceed 22 characters, otherwise, left and\n              right 11 characters will be intercepted, format: [a-zA-Z0-9]+, no special characters allowed\n  -txt T      \u9700\u8981\u89e3\u5bc6\u7684\u5b57\u7b26\u4e32 string to be decrypted\n```\n\n## \u9519\u8bef\u8bf4\u660e\n\n1. key\u5b57\u7b26\u4e32\u5982\u679c\u4e0d\u7b26\u5408\u683c\u5f0f\u8981\u6c42\uff0c\u4f1a\u629b\u51faerror\n2. \u5176\u4ed6\u5728\u89e3\u5bc6\u8fc7\u7a0b\u4e2d\u6709\u4efb\u4f55error\u90fd\u4e0d\u505a\u5904\u7406\u3002\n\n## \u53c2\u4e0e\u8d21\u732e\n\n1. Fork \u672c\u4ed3\u5e93\n2. \u65b0\u5efa Feat_xxx \u5206\u652f\n3. \u63d0\u4ea4\u4ee3\u7801\n4. \u65b0\u5efa Pull Request\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Security module for asterisk series.",
    "version": "0.1.2.516.1645",
    "project_urls": null,
    "split_keywords": [
        "encrypt",
        " decrypt",
        " security",
        " asterisk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aff04778a2d83de30d8f5d817d5d9397c2af648aa7c036f3286af7085d1cc68e",
                "md5": "8ac7b166c8136a4f59b231378bba3dd7",
                "sha256": "1ca97bbd7cf478b6bb05a9d575218c5db6440e967db239cbf6493fd73c481b5b"
            },
            "downloads": -1,
            "filename": "asterisk_security-0.1.2.516.1645-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8ac7b166c8136a4f59b231378bba3dd7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10.0",
            "size": 10790,
            "upload_time": "2024-05-16T08:45:15",
            "upload_time_iso_8601": "2024-05-16T08:45:15.734305Z",
            "url": "https://files.pythonhosted.org/packages/af/f0/4778a2d83de30d8f5d817d5d9397c2af648aa7c036f3286af7085d1cc68e/asterisk_security-0.1.2.516.1645-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7b7d19e229a91edcb57ed31435420ac2f7db5983c66528753226ef566df6822d",
                "md5": "a69862ecf54377602a1bf6fce2d98d84",
                "sha256": "bbec9638d2e76cfce649edbdd290737a31d98440db259d8075db946f1d695c5d"
            },
            "downloads": -1,
            "filename": "asterisk_security-0.1.2.516.1645.tar.gz",
            "has_sig": false,
            "md5_digest": "a69862ecf54377602a1bf6fce2d98d84",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10.0",
            "size": 10172,
            "upload_time": "2024-05-16T08:45:18",
            "upload_time_iso_8601": "2024-05-16T08:45:18.282699Z",
            "url": "https://files.pythonhosted.org/packages/7b/7d/19e229a91edcb57ed31435420ac2f7db5983c66528753226ef566df6822d/asterisk_security-0.1.2.516.1645.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-16 08:45:18",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "asterisk-security"
}
        
Elapsed time: 0.22722s