def decrypt(self, ciphertext, nonce=None, encoder=encoding.RawEncoder):
        """
        Decrypts the ciphertext using the `nonce` (explicitly, when passed as a
        parameter or implicitly, when omitted, as part of the ciphertext) and
        returns the plaintext message.

        :param ciphertext: [:class:`bytes`] The encrypted message to decrypt
        :param nonce: [:class:`bytes`] The nonce used when encrypting the
            ciphertext
        :param encoder: The encoder used to decode the ciphertext.
        :rtype: [:class:`bytes`]
        """
        # Decode our ciphertext
        ciphertext = encoder.decode(ciphertext)

        if nonce is None:
            # If we were given the nonce and ciphertext combined, split them.
            nonce = ciphertext[:self.NONCE_SIZE]
            ciphertext = ciphertext[self.NONCE_SIZE:]

        if len(nonce) != self.NONCE_SIZE:
            raise exc.ValueError("The nonce must be exactly %s bytes long" %
                                 self.NONCE_SIZE)

        plaintext = nacl.bindings.crypto_box_open_afternm(
            ciphertext,
            nonce,
            self._shared_key,
        )

        return plaintext
def decrypt ( self , ciphertext , nonce = None , encoder = encoding . RawEncoder ) : ciphertext = encoder . decode ( ciphertext ) if nonce is None : nonce = ciphertext [ : self . NONCE_SIZE ] ciphertext = ciphertext [ self . NONCE_SIZE : ] if len ( nonce ) != self . NONCE_SIZE : raise exc . ValueError ( "The nonce must be exactly %s bytes long" % self . NONCE_SIZE ) plaintext = nacl . bindings . crypto_box_open_afternm ( ciphertext , nonce , self . _shared_key , ) return plaintext
Decrypts the ciphertext using the `nonce` (explicitly, when passed as a
        parameter or implicitly, when omitted, as part of the ciphertext) and
        returns the plaintext message.

        :param ciphertext: [:class:`bytes`] The encrypted message to decrypt
        :param nonce: [:class:`bytes`] The nonce used when encrypting the
            ciphertext
        :param encoder: The encoder used to decode the ciphertext.
        :rtype: [:class:`bytes`]