This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import pytest
|
||||
from cryptography_s_des_exploring.sdes.decrypt import decrypt, decrypt_block
|
||||
|
||||
|
||||
@pytest.mark.parametrize("key, message, expected_ciphertext", [
|
||||
('1111001110', '00100001', '11110011'),
|
||||
('1111001111', '11110111', '00010011'),
|
||||
# 0b1101000 = 104 ('h')
|
||||
('1111001110', '10100011', '01101000'),
|
||||
# 0b1100101 = 101 ('e')
|
||||
('1111001110', '10000111', '01100101'),
|
||||
# 0b1101100 = 108 ('l')
|
||||
('1111001110', '11100110', '01101100'),
|
||||
# 0b1101111 = 111 ('o')
|
||||
('1111001110', '11001110', '01101111'),
|
||||
])
|
||||
def test_encrypt_block(key, message, expected_ciphertext):
|
||||
result = decrypt_block(key, message)
|
||||
assert expected_ciphertext == result
|
||||
|
||||
|
||||
@pytest.mark.parametrize("key, message, expected_ciphertext", [
|
||||
('1111001110', 'wkwaR1xMpoE=', 'hello'),
|
||||
('1111001110', 'nEp+f+C3CRmcSkp/5s1MCQ==', 'привіт'),
|
||||
])
|
||||
def test_encrypt(key, message, expected_ciphertext):
|
||||
result = decrypt(key, message)
|
||||
assert expected_ciphertext == result
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import pytest
|
||||
from cryptography_s_des_exploring.sdes.encrypt import encrypt, encrypt_block
|
||||
|
||||
|
||||
@pytest.mark.parametrize("key, message, expected_ciphertext", [
|
||||
('1111001110', '11110011', '00100001'),
|
||||
('1111001111', '00010011', '11110111'),
|
||||
# 0b1101000 = 104 ('h')
|
||||
('1111001110', '01101000', '10100011'),
|
||||
# 0b1100101 = 101 ('e')
|
||||
('1111001110', '01100101', '10000111'),
|
||||
# 0b1101100 = 108 ('l')
|
||||
('1111001110', '01101100', '11100110'),
|
||||
# 0b1101111 = 111 ('o')
|
||||
('1111001110', '01101111', '11001110'),
|
||||
])
|
||||
def test_encrypt_block(key, message, expected_ciphertext):
|
||||
result = encrypt_block(key, message)
|
||||
assert expected_ciphertext == result
|
||||
|
||||
|
||||
@pytest.mark.parametrize("key, message, expected_ciphertext", [
|
||||
('1111001110', 'hello', b'wkwaR1xMpoE='),
|
||||
('1111001110', 'привіт', b'nEp+f+C3CRmcSkp/5s1MCQ=='),
|
||||
])
|
||||
def test_encrypt(key, message, expected_ciphertext):
|
||||
result = encrypt(key, message)
|
||||
assert expected_ciphertext == result
|
||||
|
||||
Reference in New Issue
Block a user