asterisk-security


Nameasterisk-security JSON
Version 0.1.4.1203.2254 PyPI version JSON
download
home_pageNone
SummarySecurity module for asterisk series.
upload_time2024-12-03 14:56:31
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)

注意:

* 发行版本的版本号不一定连续,中间的版本号都是开发中的版本号,不正式发布。
* 版本号为A.B.C.mmdd.hhmm的格式,只须关注A.B.C即可,mmdd.hhmm为build时间戳

## 软件架构

```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/52/81/1907737550dcb133ae471ca384203c4de062c0ee5de025552c1f40c0700e/asterisk_security-0.1.4.1203.2254.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\u6ce8\u610f\uff1a\n\n* \u53d1\u884c\u7248\u672c\u7684\u7248\u672c\u53f7\u4e0d\u4e00\u5b9a\u8fde\u7eed\uff0c\u4e2d\u95f4\u7684\u7248\u672c\u53f7\u90fd\u662f\u5f00\u53d1\u4e2d\u7684\u7248\u672c\u53f7\uff0c\u4e0d\u6b63\u5f0f\u53d1\u5e03\u3002\n* \u7248\u672c\u53f7\u4e3aA.B.C.mmdd.hhmm\u7684\u683c\u5f0f\uff0c\u53ea\u987b\u5173\u6ce8A.B.C\u5373\u53ef\uff0cmmdd.hhmm\u4e3abuild\u65f6\u95f4\u6233\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.4.1203.2254",
    "project_urls": null,
    "split_keywords": [
        "encrypt",
        " decrypt",
        " security",
        " asterisk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cc74a2aa6e344bce18ca4f63ab54b2064046d6db65b1676ba8e30730ee545dd6",
                "md5": "4e9ca1365598887397f88ce430f3a88a",
                "sha256": "e60126462851c455f726d28f09a1bd1d2a997925861bd26e4debd09cad36203e"
            },
            "downloads": -1,
            "filename": "asterisk_security-0.1.4.1203.2254-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4e9ca1365598887397f88ce430f3a88a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10.0",
            "size": 11134,
            "upload_time": "2024-12-03T14:56:29",
            "upload_time_iso_8601": "2024-12-03T14:56:29.114738Z",
            "url": "https://files.pythonhosted.org/packages/cc/74/a2aa6e344bce18ca4f63ab54b2064046d6db65b1676ba8e30730ee545dd6/asterisk_security-0.1.4.1203.2254-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "52811907737550dcb133ae471ca384203c4de062c0ee5de025552c1f40c0700e",
                "md5": "43a107586fa8dd3f7f1597af4007349c",
                "sha256": "75cc112dd4ac5d0dbf329ef9b3942c2101d95a4e3fe413435e35322b9811de56"
            },
            "downloads": -1,
            "filename": "asterisk_security-0.1.4.1203.2254.tar.gz",
            "has_sig": false,
            "md5_digest": "43a107586fa8dd3f7f1597af4007349c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10.0",
            "size": 10522,
            "upload_time": "2024-12-03T14:56:31",
            "upload_time_iso_8601": "2024-12-03T14:56:31.147279Z",
            "url": "https://files.pythonhosted.org/packages/52/81/1907737550dcb133ae471ca384203c4de062c0ee5de025552c1f40c0700e/asterisk_security-0.1.4.1203.2254.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-03 14:56:31",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "asterisk-security"
}
        
Elapsed time: 0.45667s