Utilities

class nacl.utils.EncryptedMessage[source]

A bytes subclass that holds a message that has been encrypted by a SecretBox or Box. The full content of the bytes object is the combined nonce and ciphertext.

nonce

The nonce used during the encryption of the EncryptedMessage.

ciphertext

The ciphertext contained within the EncryptedMessage.

nacl.utils.random(size=32)[source]

Returns a random bytestring with the given size.

Parameters:

size (bytes) – The size of the random bytestring.

Return bytes:

The random bytestring.

nacl.utils.randombytes_deterministic(size, seed, encoder=encoding.RawEncoder)[source]

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

Parameters:
  • size (bytes) – The size of the random bytestring.

  • seed (bytes) – The seed for the bytestring. This should be 32 bytes or a TypeError will be thrown.

  • encoder – The encoder class used to encode the produced bytes.

Return bytes:

The random bytestring.