caellion-python-commons: tests/test_encryption_tripledes.py Source File

caellion-python-commons

test_encryption_tripledes.py
Go to the documentation of this file.
1 # test framework
2 import unittest
3 import pytest
4
5 # package
6 from caellion.pycommons.encryption.tripledes import TripleDESECBMD5Key
7
8
9 # test cases
10 class TestSerializersDateTimeSerializer():
11 @pytest.mark.parametrize( "key,data,expected", [ ("C_STRVAL", "talex3_@1234", "2cYkHeYSxop72P7ZjibhVg=="), ("C_STRVAL", "talex3_@", "2cYkHeYSxoo9Zv/jq+D5Ng=="), ("C_STRVAL", "1234", "e9j+2Y4m4VY="), ("StringChar", "talex3_@1234", "vUgc8L0ArdVK+zLD4VfKhQ=="), ("StringChar", "talex3_@", "vUgc8L0ArdWQCHcU1cgi/Q=="), ("StringChar", "1234", "Svsyw+FXyoU="), ("CharString", "talex3_@1234", "t9rKj1W8bQRmV9nNTRnqvQ=="), ("CharString", "talex3_@", "t9rKj1W8bQQsBVpqtOg5lw=="), ("CharString", "1234", "ZlfZzU0Z6r0="),
12 ]
13 )
14 def test_tripledes_ECB_MD5Key_encrypt(self, key, data, expected):
15 DES = TripleDESECBMD5Key(key)
16 data_ = DES.encrypt(data)
17 assert data_ == expected
18
19 @pytest.mark.parametrize( "key,expected,data", [ ("C_STRVAL", "talex3_@1234", "2cYkHeYSxop72P7ZjibhVg=="), ("C_STRVAL", "talex3_@", "2cYkHeYSxoo9Zv/jq+D5Ng=="), ("C_STRVAL", "1234", "e9j+2Y4m4VY="), ("StringChar", "talex3_@1234", "vUgc8L0ArdVK+zLD4VfKhQ=="), ("StringChar", "talex3_@", "vUgc8L0ArdWQCHcU1cgi/Q=="), ("StringChar", "1234", "Svsyw+FXyoU="), ("CharString", "talex3_@1234", "t9rKj1W8bQRmV9nNTRnqvQ=="), ("CharString", "talex3_@", "t9rKj1W8bQQsBVpqtOg5lw=="), ("CharString", "1234", "ZlfZzU0Z6r0="),
20 ]
21 )
22 def test_tripledes_ECB_MD5Key_decrypt(self, key, expected, data):
23 DES = TripleDESECBMD5Key(key)
24 data_ = DES.decrypt(data)
25 assert data_ == expected
26
27
28 if __name__ == "__main__":
29 unittest.main()
30
caellion.pycommons.encryption.tripledes.TripleDESECBMD5Key
This class provides implementation of triple DES algorithm which uses MD5 hash of password as a key (...
Definition: tripledes.py:11
tests.test_encryption_tripledes.TestSerializersDateTimeSerializer
Definition: test_encryption_tripledes.py:10
tests.test_encryption_tripledes.TestSerializersDateTimeSerializer.test_tripledes_ECB_MD5Key_encrypt
def test_tripledes_ECB_MD5Key_encrypt(self, key, data, expected)
Definition: test_encryption_tripledes.py:14
tests.test_encryption_tripledes.TestSerializersDateTimeSerializer.test_tripledes_ECB_MD5Key_decrypt
def test_tripledes_ECB_MD5Key_decrypt(self, key, expected, data)
Definition: test_encryption_tripledes.py:22
caellion.pycommons.encryption.tripledes
This module provides utilities related to or using 3DES symmetric encryption algorithm.
Definition: tripledes.py:1