keyvault-sdk


Namekeyvault-sdk JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
Summary密钥管理服务的Python SDK
upload_time2024-11-05 08:16:50
maintainerNone
docs_urlNone
authorsingle.wong
requires_python>=3.7.5
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # keyvault_sdk

密钥管理Python SDK

## 使用示例

### AES
```bash
from key_sdk.client import AESKeyClient
# AES测试示例
kwargs = {
    'host': 'http://127.0.0.1:9094',
    'app_name': 'test',
    'app_secret': '1111111111111',
    'aes_key_sid': 'sid-xxxxxxxxxxxxxxx',
}
# 要加密的明文
plaintext = b'\x80\xbd\x81=\xb9\xcf(\xc0eI\xe8\x1de\xf4\xc2\x1b\\|gVh\xe73\xa4\r\x97\xb2\xe1f\x90(\x88'
aes_key_client = AESKeyClient(**kwargs)
ciphertext_base64 = aes_key_client.encrypt(plaintext)
print("Ciphertext (Base64):", ciphertext_base64)
decrypted_text = aes_key_client.decrypt(ciphertext_base64)
print("Decrypted Text:", decrypted_text)
```

### RSA
```bash
from key_sdk.client import RSAKeyClient
# RSA测试示例
kwargs = {
    'host': 'http://127.0.0.1:9094',
    'app_name': 'test',
    'app_secret': '1111111111111',
    'rsa_private_key_sid': 'sid-yyyyyyyyyyyyy',
}
public_key = """-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArg4ZTp1AhXY9LJ01nNDd
lST/JaNnG7Ne+9x6XCzwmwkXRzAQbKGgygBqlTdfqqdT+rwwa2FEeebxw4JuiMsl
XapUvYCxrPSdQB3ItH7Gm4rzaCrs6nXjhZozHUEYEP2+ylb77QxW+FwBr0aMuo6q
M2qsyk2nTN5Y7Kq2gsIyQcwAsRQpJk9+oUvrYbWZwjFo/l2ilJI1MKY9N5lJ/FUR
olCkVkKqXyHm2+fpnLCjnJKZS54idkiQzomE85VbGUw7ZDjl3k6NwLC+2Mt4qgFx
Z5ElOAkXdG1S3xCy466uNyw1fr+8QnkyCRwJuIr5Ww5v8njbzwV/FiednELat8oY
uQIDAQAB
-----END PUBLIC KEY-----"""
# 要加密的明文
plaintext = b'\x80\xbd\x81=\xb9\xcf(\xc0eI\xe8\x1de\xf4\xc2\x1b\\|gVh\xe73\xa4\r\x97\xb2\xe1f\x90(\x88'
rsa_key_client = RSAKeyClient(**kwargs)
rsa_key_client.rsa_client.public_key = public_key  # 如果不需要RSA公钥加密,则忽略这一步
ciphertext_base64 = rsa_key_client.encrypt(plaintext)
print("Ciphertext (Base64):", ciphertext_base64)
decrypted_text = rsa_key_client.decrypt(ciphertext_base64)
print("Decrypted Text:", decrypted_text)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "keyvault-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7.5",
    "maintainer_email": null,
    "keywords": null,
    "author": "single.wong",
    "author_email": "wongsingle@163.com",
    "download_url": "https://files.pythonhosted.org/packages/35/91/3c31c1aaf7412094eb79c9b358427e4712f7d8a8c7e6b3e154aef4b2cc61/keyvault_sdk-0.1.1.tar.gz",
    "platform": null,
    "description": "# keyvault_sdk\n\n\u5bc6\u94a5\u7ba1\u7406Python SDK\n\n## \u4f7f\u7528\u793a\u4f8b\n\n### AES\n```bash\nfrom key_sdk.client import AESKeyClient\n# AES\u6d4b\u8bd5\u793a\u4f8b\nkwargs = {\n    'host': 'http://127.0.0.1:9094',\n    'app_name': 'test',\n    'app_secret': '1111111111111',\n    'aes_key_sid': 'sid-xxxxxxxxxxxxxxx',\n}\n# \u8981\u52a0\u5bc6\u7684\u660e\u6587\nplaintext = b'\\x80\\xbd\\x81=\\xb9\\xcf(\\xc0eI\\xe8\\x1de\\xf4\\xc2\\x1b\\\\|gVh\\xe73\\xa4\\r\\x97\\xb2\\xe1f\\x90(\\x88'\naes_key_client = AESKeyClient(**kwargs)\nciphertext_base64 = aes_key_client.encrypt(plaintext)\nprint(\"Ciphertext (Base64):\", ciphertext_base64)\ndecrypted_text = aes_key_client.decrypt(ciphertext_base64)\nprint(\"Decrypted Text:\", decrypted_text)\n```\n\n### RSA\n```bash\nfrom key_sdk.client import RSAKeyClient\n# RSA\u6d4b\u8bd5\u793a\u4f8b\nkwargs = {\n    'host': 'http://127.0.0.1:9094',\n    'app_name': 'test',\n    'app_secret': '1111111111111',\n    'rsa_private_key_sid': 'sid-yyyyyyyyyyyyy',\n}\npublic_key = \"\"\"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArg4ZTp1AhXY9LJ01nNDd\nlST/JaNnG7Ne+9x6XCzwmwkXRzAQbKGgygBqlTdfqqdT+rwwa2FEeebxw4JuiMsl\nXapUvYCxrPSdQB3ItH7Gm4rzaCrs6nXjhZozHUEYEP2+ylb77QxW+FwBr0aMuo6q\nM2qsyk2nTN5Y7Kq2gsIyQcwAsRQpJk9+oUvrYbWZwjFo/l2ilJI1MKY9N5lJ/FUR\nolCkVkKqXyHm2+fpnLCjnJKZS54idkiQzomE85VbGUw7ZDjl3k6NwLC+2Mt4qgFx\nZ5ElOAkXdG1S3xCy466uNyw1fr+8QnkyCRwJuIr5Ww5v8njbzwV/FiednELat8oY\nuQIDAQAB\n-----END PUBLIC KEY-----\"\"\"\n# \u8981\u52a0\u5bc6\u7684\u660e\u6587\nplaintext = b'\\x80\\xbd\\x81=\\xb9\\xcf(\\xc0eI\\xe8\\x1de\\xf4\\xc2\\x1b\\\\|gVh\\xe73\\xa4\\r\\x97\\xb2\\xe1f\\x90(\\x88'\nrsa_key_client = RSAKeyClient(**kwargs)\nrsa_key_client.rsa_client.public_key = public_key  # \u5982\u679c\u4e0d\u9700\u8981RSA\u516c\u94a5\u52a0\u5bc6\uff0c\u5219\u5ffd\u7565\u8fd9\u4e00\u6b65\nciphertext_base64 = rsa_key_client.encrypt(plaintext)\nprint(\"Ciphertext (Base64):\", ciphertext_base64)\ndecrypted_text = rsa_key_client.decrypt(ciphertext_base64)\nprint(\"Decrypted Text:\", decrypted_text)\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "\u5bc6\u94a5\u7ba1\u7406\u670d\u52a1\u7684Python SDK",
    "version": "0.1.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dbc5d4ff20a43794c4ef34b259946408a81242187dc35a063103542f1c0cf8a3",
                "md5": "bfc5180de40414e3dd0ebbac46d6b3b7",
                "sha256": "c3171da249b5a1911d98b616301c85f45b78f14f99677718eb2919eda8aa1a1f"
            },
            "downloads": -1,
            "filename": "keyvault_sdk-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bfc5180de40414e3dd0ebbac46d6b3b7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7.5",
            "size": 7188,
            "upload_time": "2024-11-05T08:16:48",
            "upload_time_iso_8601": "2024-11-05T08:16:48.742016Z",
            "url": "https://files.pythonhosted.org/packages/db/c5/d4ff20a43794c4ef34b259946408a81242187dc35a063103542f1c0cf8a3/keyvault_sdk-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "35913c31c1aaf7412094eb79c9b358427e4712f7d8a8c7e6b3e154aef4b2cc61",
                "md5": "5f665591dab5b07c9f1f73ae1e9aa155",
                "sha256": "0071cc36dfba878478c0e8f8123869a344972a72fa6c25ae295ac8e20f282189"
            },
            "downloads": -1,
            "filename": "keyvault_sdk-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5f665591dab5b07c9f1f73ae1e9aa155",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.5",
            "size": 5746,
            "upload_time": "2024-11-05T08:16:50",
            "upload_time_iso_8601": "2024-11-05T08:16:50.807139Z",
            "url": "https://files.pythonhosted.org/packages/35/91/3c31c1aaf7412094eb79c9b358427e4712f7d8a8c7e6b3e154aef4b2cc61/keyvault_sdk-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-05 08:16:50",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "keyvault-sdk"
}
        
Elapsed time: 0.36462s