-
Notifications
You must be signed in to change notification settings - Fork 6
/
test_pbe_with_md5_and_des.py
executable file
·38 lines (31 loc) · 1.45 KB
/
test_pbe_with_md5_and_des.py
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
31
32
33
34
35
36
37
38
from pbe_with_md5_and_triple_des import PBEWithMD5AndDES, PBEWithMD5AndTripleDES
def test_pbe_with_md5_and_des():
password = 'secret'
plain_text = 'Hello World!'
cipher = PBEWithMD5AndDES()
encrypted_text = cipher.encrypt(plain_text, password)
decrypted_text = cipher.decrypt(encrypted_text, password)
assert plain_text == decrypted_text
def test_pbe_with_md5_and_triple_des():
password = 'secret'
plain_text = 'Hello World!'
cipher = PBEWithMD5AndTripleDES()
encrypted_text = cipher.encrypt(plain_text, password)
decrypted_text = cipher.decrypt(encrypted_text, password)
assert plain_text == decrypted_text
def test_pbe_with_md5_and_triple_des_decryption():
"""
Some prepared examples, encoded using Jasypt lib for Java.
"""
test_data = [
('hello', 'NiwUbfH5mSK9HhsgntENfA==', 'abcd1234'),
('hello', 'AGxuQtY9J/XUoGqUrUlCNQ==', 'abcd1234'),
('hello', 'LYgMLQSth4/iaNvLwYfvdQ==', 'abcd1234'),
('hello', 'YSJ3IhOw6xGOGR82vCMggg==', 'mnopqrst'),
('hello', 'hOG75IYw+KR5G/oKRPZReQ==', 'mnopqrst'),
('hello', 'BYi598iZOU8QITOWkmbmDg==', 'mnopqrst'),
]
cipher = PBEWithMD5AndTripleDES()
for td in test_data:
decrypted_text = cipher.decrypt(td[1], td[2])
assert td[0] == decrypted_text