caellion-python-commons
test_encryption_tripledes.py
Go to the documentation of this file.
1 # test framework
2 import unittest
3 from nose2.tools import params
4 
5 # package
6 from caellion.pycommons.encryption.tripledes import TripleDESECBMD5Key
7 
8 
9 # test cases
10 class TestSerializersDateTimeSerializer(unittest.TestCase):
11  @params(
12  ("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="),
13  )
14  def test_tripledes_ECB_MD5Key_encrypt(self, key, data, expected):
15  DES = TripleDESECBMD5Key(key)
16  data_ = DES.encrypt(data)
17  self.assertEqual(data_, expected)
18 
19  @params(
20  ("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="),
21  )
22  def test_tripledes_ECB_MD5Key_decrypt(self, key, expected, data):
23  DES = TripleDESECBMD5Key(key)
24  data_ = DES.decrypt(data)
25  self.assertEqual(data_, expected)
26 
27 
28 if __name__ == "__main__":
29  unittest.main()
This class provides implementation of triple DES algorithm which uses MD5 hash of password as a key (...
Definition: tripledes.py:10
This module provides utilities related to or using 3DES symmetric encryption algorithm.
Definition: tripledes.py:1