Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

key.py 679B

123456789101112131415161718192021222324252627
  1. # -*- coding: utf-8 -*-
  2. """
  3. celery.security.key
  4. ~~~~~~~~~~~~~~~~~~~
  5. Private key for the security serializer.
  6. """
  7. from __future__ import absolute_import
  8. from kombu.utils.encoding import ensure_bytes
  9. from .utils import crypto, reraise_errors
  10. __all__ = ['PrivateKey']
  11. class PrivateKey(object):
  12. def __init__(self, key):
  13. with reraise_errors('Invalid private key: {0!r}'):
  14. self._key = crypto.load_privatekey(crypto.FILETYPE_PEM, key)
  15. def sign(self, data, digest):
  16. """sign string containing data."""
  17. with reraise_errors('Unable to sign data: {0!r}'):
  18. return crypto.sign(self._key, ensure_bytes(data), digest)