Debug stmts for enc/dev
This commit is contained in:
parent
1030de6fca
commit
1a1c3307b0
18
04_qkd_2.py
18
04_qkd_2.py
@ -96,7 +96,14 @@ def encrypt_message(message, otp):
|
||||
return
|
||||
|
||||
# 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):
|
||||
@ -109,8 +116,15 @@ def decrypt_message(encrypted_bits, otp):
|
||||
"""
|
||||
_decrypted_bits = [m_b ^ otp_b
|
||||
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():
|
||||
|
Loading…
Reference in New Issue
Block a user