Add test for keccak_digest

pull/74/head
tuxxy 2017-10-10 16:14:49 -06:00
parent 2263678c76
commit 8269e5c396
1 changed files with 18 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import unittest
import random
import sha3
from nacl.utils import EncryptedMessage
from npre import umbral
from npre import elliptic_curve as ec
@ -42,6 +43,23 @@ class TestCrypto(unittest.TestCase):
self.assertNotIn(2, output)
self.assertIn(1, output)
def test_keccak_digest(self):
data = b'this is a test'
digest1 = sha3.keccak_256(data).digest()
digest2 = Crypto.keccak_digest(data)
self.assertEqual(digest1, digest2)
# Test iterables
data = data.split()
digest1 = sha3.keccak_256(b''.join(data)).digest()
digest2 = Crypto.keccak_digest(*data)
self.assertEqual(digest1, digest2)
def test_symm_encrypt(self):
key = random._urandom(32)
plaintext = b'this is a test'