I created a simple XOR program for fun on python which takes a message and encrypts it against a running key cipher. The code is shown below:
#Key
sox = bin(int.from_bytes('FABRICATING'.encode(), 'big'))
#Plaintext Message
box = bin(int.from_bytes('PEACEMAKERS'.encode(), 'big'))
#XORing
if sox[0] == box[0]:
dox0 = 0
else:
dox0 = 1
if sox[2] == box[2]:
dox1 = 0
else:
dox1 = 1
if sox[3] == box[3]:
dox2 = 0
else:
dox2 = 1
if sox[4] == box[4]:
dox3 = 0
else:
dox3 = 1
if sox[5] == box[5]:
dox4 = 0
else:
dox4 = 1
if sox[6] == box[6]:
dox5 = 0
else:
dox5 = 1
. . . etc
My question is; can I create code, particularly a function that executes variables in ascending/descending order?
When I create a while loop function and have the list return after adding =+ 1 it only returns 1 outcome. I understand return breaks the loop even if its not done compiling.
Any work around for this or should the code be manually written as shown above? I'd like to ideally keep the code DRY, though repeating the input is the only way I got my program to work.
Thank you.
Aucun commentaire:
Enregistrer un commentaire