Spaces:
Running
Running
File size: 914 Bytes
92c34be |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import unittest
from chainguard.encryption import AESCipher
class TestAESCipher(unittest.TestCase):
def setUp(self):
self.password = "securepassword123"
self.cipher = AESCipher(self.password)
def test_encryption_decryption(self):
plaintext = "This is a secret message."
encrypted = self.cipher.encrypt(plaintext)
decrypted = self.cipher.decrypt(encrypted)
self.assertEqual(plaintext, decrypted)
def test_different_plaintext(self):
plaintext1 = "Message One"
plaintext2 = "Message Two"
encrypted1 = self.cipher.encrypt(plaintext1)
encrypted2 = self.cipher.encrypt(plaintext2)
self.assertNotEqual(encrypted1, encrypted2)
self.assertEqual(self.cipher.decrypt(encrypted1), plaintext1)
self.assertEqual(self.cipher.decrypt(encrypted2), plaintext2)
if __name__ == '__main__':
unittest.main()
|