Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

keyutils bindings for Python

Project Description

python-keyutils is a set of python bindings for keyutils (available from, a key management suite that leverages the infrastructure provided by the Linux kernel for safely storing and retrieving sensitive infromation in your programs.


The C extension module follows closely the C API (see add_key(2), request_key(2), keyctl_read_alloc(2)).

Exceptions also follow the C API. The only notable difference is for request_key: when the key is not present, None is returned, instead of raising an exception (which is usually a more expensive operation).

Note that the function parameters are passed as bytes not strings! On python 3 this usually requires an explicit param.encode() call.

For example:

import keyutils

# NOTE: only pass `bytes` to the keyutils API:
name = b'foo'
value = b'bar'

key_id = keyutils.add_key(name, value, ring)

assert keyutils.request_key(name, ring) == key_id
assert keyutils.read_key(key_id) == value

# set timeout to 5 seconds, wait and then... it's gone:
keyutils.set_timeout(key_id, 5)
from time import sleep
assert keyutils.request_key(name, ring) == None

Further examples can be found in the test subfolder.

Release History

This version
History Node


History Node


History Node


History Node


History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(36.2 kB) Copy SHA256 Hash SHA256
Source None Aug 11, 2017

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting