你正在阅读 Celery 3.1 的文档。开发版本文档见: 此处.
# -*- coding: utf-8 -*-
"""
celery.security.key
~~~~~~~~~~~~~~~~~~~
Private key for the security serializer.
"""
from __future__ import absolute_import
from __future__ import with_statement
from .utils import crypto, reraise_errors
[文档]class PrivateKey(object):
def __init__(self, key):
with reraise_errors('Invalid private key: %r'):
self._key = crypto.load_privatekey(crypto.FILETYPE_PEM, key)
[文档] def sign(self, data, digest):
"""sign string containing data."""
with reraise_errors('Unable to sign data: %r'):
return crypto.sign(self._key, data, digest)