INNER CODE UNIT · Python
sxor
rishitsaiya/CTFlearn-Writeups · Cryptography/ALEXCTF CR2: Many time secrets/cribdrag.py:17
def sxor(ctext,crib):
# convert strings to a list of character pair tuples
# go through each tuple, converting them to ASCII code (ord)
# perform exclusive or on the ASCII code
# then convert the result back to ASCII (chr)
# merge the resulting array of characters as a string
results = []
single_result = ''
crib_len = len(crib)
positions = len(ctext)-crib_len+1
for index in xrange(positions):
single_result = ''
for a,b in zip(ctext[index:index+crib_len],crib):
single_result += chr(ord(a) ^ ord(b))
results.append(single_result)
return results
def print_linewrapped(text):