Name | keyvault-sdk JSON |
Version |
0.1.2
JSON |
| download |
home_page | None |
Summary | 密钥管理服务的Python SDK |
upload_time | 2024-12-12 03:25:04 |
maintainer | None |
docs_url | None |
author | single.wong |
requires_python | >=3.7.5 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# keyvault_sdk
密钥管理Python SDK
## 使用示例
### 安装sdk
```bash
pip install keyvault-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/b0/77/a59c22dfe9b240f47c3e793bb7b182695289f61d41a2ccaecba22f858b8d/keyvault_sdk-0.1.2.tar.gz",
"platform": null,
"description": "# keyvault_sdk\n\n\u5bc6\u94a5\u7ba1\u7406Python SDK\n\n## \u4f7f\u7528\u793a\u4f8b\n\n### \u5b89\u88c5sdk\n```bash\npip install keyvault-sdk\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.2",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f201d4b2ae7341c59f5dc5a1fec3266acd73d848e02d4c8c5ac119a42750f40d",
"md5": "14630daec7bfca2c02b724ee96d64540",
"sha256": "77f7cd197bbf6b94b39f0368efa4790fa773866f2a3042319ee8ff6a027c4b48"
},
"downloads": -1,
"filename": "keyvault_sdk-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "14630daec7bfca2c02b724ee96d64540",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.5",
"size": 7408,
"upload_time": "2024-12-12T03:25:00",
"upload_time_iso_8601": "2024-12-12T03:25:00.491127Z",
"url": "https://files.pythonhosted.org/packages/f2/01/d4b2ae7341c59f5dc5a1fec3266acd73d848e02d4c8c5ac119a42750f40d/keyvault_sdk-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b077a59c22dfe9b240f47c3e793bb7b182695289f61d41a2ccaecba22f858b8d",
"md5": "28f3b7ec7a54a8a4778ac4c668429c83",
"sha256": "13b42114745a2deafe2f31c87c26186a8aa80cd11864259c9592ea13ed24d8eb"
},
"downloads": -1,
"filename": "keyvault_sdk-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "28f3b7ec7a54a8a4778ac4c668429c83",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7.5",
"size": 6709,
"upload_time": "2024-12-12T03:25:04",
"upload_time_iso_8601": "2024-12-12T03:25:04.883227Z",
"url": "https://files.pythonhosted.org/packages/b0/77/a59c22dfe9b240f47c3e793bb7b182695289f61d41a2ccaecba22f858b8d/keyvault_sdk-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-12 03:25:04",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "keyvault-sdk"
}