Skip to main content

密钥管理SDK-0.1.3:添加记录解密日志功能

Project description

keyvault_sdk

密钥管理Python SDK

使用示例

安装sdk

pip install keyvault-sdk

AES

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)
# 解密时须传入必要字段
kwargs = {
    "ad_account": "san.zhang", 
    "ciphertext_class": "CustomerInfo",
    "ciphertext_hash": "d17f25ecfbcc7857f7bebea469308be0b2580943e96d13a3ad98a13675c4bfc2",
    "ciphertext_type": "手机号",
    "system_name": "finder", 
    "username": "张三"
}
decrypted_text = aes_key_client.decrypt(ciphertext_base64, **kwargs)
print("Decrypted Text:", decrypted_text)

RSA

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keyvault_sdk-0.1.3.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keyvault_sdk-0.1.3-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file keyvault_sdk-0.1.3.tar.gz.

File metadata

  • Download URL: keyvault_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for keyvault_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 b55b532c4c934670c2f11da2c9306c40d780d8aa05a11dd7fe9f642ea202ab7e
MD5 89d88b9d7c59c06c338e8b74b1219691
BLAKE2b-256 05ce2fc8b08d5f3ddee05878aeb704b6b5e384c075c8164d2f6e8c021c49f744

See more details on using hashes here.

File details

Details for the file keyvault_sdk-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: keyvault_sdk-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for keyvault_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0c3edbfe5cb5351e267a6a605cc03b5e1d4bd9d7d3ad89edc43a9bfe730df688
MD5 6608f0536afd9a4052c096424f5e9e7a
BLAKE2b-256 3db42216f42542325f633b03339a26f74718f58ff083ca77d89afff49aace476

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page