ucryptolib.rst 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. :mod:`ucryptolib` -- cryptographic ciphers
  2. ==========================================
  3. .. module:: ucryptolib
  4. :synopsis: cryptographic ciphers
  5. Classes
  6. -------
  7. .. class:: aes
  8. .. classmethod:: __init__(key, mode, [IV])
  9. Initialize cipher object, suitable for encryption/decryption. Note:
  10. after initialization, cipher object can be use only either for
  11. encryption or decryption. Running decrypt() operation after encrypt()
  12. or vice versa is not supported.
  13. Parameters are:
  14. * *key* is an encryption/decryption key (bytes-like).
  15. * *mode* is:
  16. * ``1`` (or ``ucryptolib.MODE_ECB`` if it exists) for Electronic Code Book (ECB).
  17. * ``2`` (or ``ucryptolib.MODE_CBC`` if it exists) for Cipher Block Chaining (CBC)
  18. * *IV* is an initialization vector for CBC mode.
  19. .. method:: encrypt(in_buf, [out_buf])
  20. Encrypt *in_buf*. If no *out_buf* is given result is returned as a
  21. newly allocated `bytes` object. Otherwise, result is written into
  22. mutable buffer *out_buf*. *in_buf* and *out_buf* can also refer
  23. to the same mutable buffer, in which case data is encrypted in-place.
  24. .. method:: decrypt(in_buf, [out_buf])
  25. Like `encrypt()`, but for decryption.