1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
# Import nacl libs
import libnacl
import libnacl.utils
# Import python libs
import unittest
class TestSecretBox(unittest.TestCase):
'''
Test sign functions
'''
def test_secret_box_easy(self):
msg = b'Are you suggesting coconuts migrate?'
sk1 = libnacl.utils.salsa_key()
nonce1 = libnacl.utils.rand_nonce()
enc_msg = libnacl.crypto_secretbox_easy(msg, nonce1, sk1)
self.assertNotEqual(msg, enc_msg)
clear_msg = libnacl.crypto_secretbox_open_easy(enc_msg, nonce1, sk1)
self.assertEqual(msg, clear_msg)
|