Debug stmts for enc/dev

This commit is contained in:
Daniel Tsvetkov 2019-12-02 17:40:40 +01:00
parent 1030de6fca
commit 1a1c3307b0

View File

@ -96,7 +96,14 @@ def encrypt_message(message, otp):
return return
# XOR the message to be sent # XOR the message to be sent
return [m_b ^ otp_b for m_b, otp_b in zip(binary_message, otp)] encrypted_message = [m_b ^ otp_b for m_b, otp_b in zip(binary_message, otp)]
if DEBUG:
print("Bin msg: {}".format(binary_message))
print("OTP: {}".format(otp))
print("Enc: {}".format(encrypted_message))
print("Alice sends Enc")
return encrypted_message
def decrypt_message(encrypted_bits, otp): def decrypt_message(encrypted_bits, otp):
@ -109,8 +116,15 @@ def decrypt_message(encrypted_bits, otp):
""" """
_decrypted_bits = [m_b ^ otp_b _decrypted_bits = [m_b ^ otp_b
for m_b, otp_b in zip(encrypted_bits, otp)] for m_b, otp_b in zip(encrypted_bits, otp)]
_decrypted_msg = binary_to_unicode_message(_decrypted_bits)
return binary_to_unicode_message(_decrypted_bits) if DEBUG:
print("Bob receives Enc")
print("Enc: {}".format(encrypted_bits))
print("OTP: {}".format(otp))
print("Bin msg: {}".format(_decrypted_bits))
return _decrypted_msg
def run_qbit_tests(): def run_qbit_tests():