File: utils.rst

package info (click to toggle)
python-nacl 1.5.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,776 kB
  • sloc: ansic: 45,889; python: 7,249; sh: 6,752; asm: 2,974; makefile: 1,011; cs: 35; xml: 30; pascal: 11
file content (38 lines) | stat: -rw-r--r-- 1,212 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Utilities
=========

.. currentmodule:: nacl.utils

.. class:: EncryptedMessage

    A ``bytes`` subclass that holds a message that has been encrypted by a
    :class:`~nacl.secret.SecretBox` or :class:`~nacl.public.Box`. The full
    content of the ``bytes`` object is the combined ``nonce`` and
    ``ciphertext``.

    .. attribute:: nonce

        The nonce used during the encryption of the :class:`EncryptedMessage`.

    .. attribute:: ciphertext

        The ciphertext contained within the :class:`EncryptedMessage`.

.. function:: random(size=32)

    Returns a random bytestring with the given ``size``.

    :param bytes size: The size of the random bytestring.
    :return bytes: The random bytestring.

.. function:: randombytes_deterministic(size, seed, encoder=encoding.RawEncoder)

    Returns ``size`` number of deterministically generated pseudorandom bytes
    from a 32 byte seed.

    :param bytes size: The size of the random bytestring.
    :param bytes seed: The seed for the bytestring. This should be 32 bytes
                            or a TypeError will be thrown.
    :param encoder: The encoder class used to encode the produced bytes.
    :return bytes: The random bytestring.