def test_secretbox(self): nonce = nacl.randombytes(nacl.crypto_secretbox_NONCEBYTES) c = nacl.crypto_secretbox(self.msg, nonce, self.k) m = nacl.crypto_secretbox_open(c, nonce, self.k) self.assertEqual(m, self.msg)
def decrypt_nacl(data, secret): n, data = data[:nacl.crypto_secretbox_NONCEBYTES], data[nacl.crypto_secretbox_NONCEBYTES:] return nacl.crypto_secretbox_open(data, n, secret)