A Pythonic client for IBM Key Protect
Project description
python-keyprotect
A Pythonic client for IBM Key Protect
This is a thin wrapper around the KeyProtect client in the redstone Python package. For detailed documentation and API references, please see the redstone docs
Usage
The following python is a quick example of how to use the keyprotect module.
The example expects IBMCLOUD_API_KEY
to be set to a valid IAM API key,
and KP_INSTANCE_ID
to be set to the UUID identifying your KeyProtect instance.
import os import keyprotect from keyprotect import bxauth tm = bxauth.TokenManager(api_key=os.getenv("IBMCLOUD_API_KEY")) kp = keyprotect.Client( credentials=tm, region="us-south", service_instance_id=os.getenv("KP_INSTANCE_ID") ) for key in kp.keys(): print("%s\t%s" % (key["id"], key["name"])) key = kp.create(name="MyTestKey") print("Created key '%s'" % key['id']) kp.delete(key.get('id')) print("Deleted key '%s'" % key['id']) # wrap and unwrap require a non-exportable key, # these are also referred to as root keys key = kp.create(name="MyRootKey", root=True) # wrap/unwrap, payload should be a bytestring if python3 message = b'This is a really important message.' wrapped = kp.wrap(key.get('id'), message) ciphertext = wrapped.get("ciphertext") unwrapped = kp.unwrap(key.get('id'), ciphertext) assert message == unwrapped # wrap/unwrap with AAD message = b'This is a really important message too.' wrapped = kp.wrap(key.get('id'), message, aad=['python-keyprotect']) ciphertext = wrapped.get("ciphertext") unwrapped = kp.unwrap(key.get('id'), ciphertext, aad=['python-keyprotect']) assert message == unwrapped
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size keyprotect-2.0.0-py3-none-any.whl (6.6 kB) | File type Wheel | Python version py3 | Upload date | Hashes View |
Filename, size keyprotect-2.0.0.tar.gz (2.4 kB) | File type Source | Python version None | Upload date | Hashes View |
Close
Hashes for keyprotect-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5fbaa530cac53a88ea03e9958b14f3819fe31f077a5e2b896c4adf258b209d1 |
|
MD5 | 091d7d44bdebc1f7600b557a8c3aefe3 |
|
BLAKE2-256 | 22b2afab9b2b292ae555ff32120e0364dc19bc461ec307c141bfec1004fc6a2b |