Path: blob/master/special_endings/source/encode.py
650 views
import base6412flag = "011010010110110001101100010111110110110101101001011100110111001101011111011110010110111101110101"34alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"56outfile = open("encrypted_lines.txt", "w")7with open("quotes.txt") as f:8for line in f:9encoded = base64.standard_b64encode(bytes(line.rstrip()))10if (encoded.rstrip().endswith("==") and flag != ""):11shift = flag[:4]12flag = flag[4:]13charToChange = encoded[-3:-2]14offset = int(shift, 2)15newChar = (alphabet[alphabet.find(charToChange[:1]) + offset])16encoded = encoded[:-3] + newChar + "=="17elif (encoded.rstrip().endswith("=") and flag != ""):18shift = flag[:2]19flag = flag[2:]20charToChange = encoded[-2:-1]21offset = int(shift, 2)22newChar = (alphabet[alphabet.find(charToChange[:1]) + offset])23encoded = encoded[:-2] + newChar + "="24outfile.write(encoded + "\n")25outfile.close()262728