File: test_secret_easy.py

package info (click to toggle)
python-libnacl 2.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 488 kB
  • sloc: python: 2,634; makefile: 149; sh: 3
file content (22 lines) | stat: -rw-r--r-- 680 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Import libnacl libs
import libnacl.secret_easy
# Import python libs
import unittest

class TestSecretEasy(unittest.TestCase):
    '''
    '''
    def test_secret(self):
        msg = b'But then of course African swallows are not migratory.'
        box = libnacl.secret_easy.SecretBoxEasy()
        ctxt = box.encrypt(msg)
        self.assertNotEqual(msg, ctxt)
        box2 = libnacl.secret_easy.SecretBoxEasy(box.sk)
        clear1 = box.decrypt(ctxt)
        self.assertEqual(msg, clear1)
        clear2 = box2.decrypt(ctxt)
        self.assertEqual(clear1, clear2)
        ctxt2 = box2.encrypt(msg)
        clear3 = box.decrypt(ctxt2)
        self.assertEqual(clear3, msg)