#! /usr/bin/env python from AES_128 import AES_128_CTR, gen_rand_data from binascii import a2b_base64 from random import randint key = gen_rand_data() nonce = randint(0,2**64-1) ciphertexts = [AES_128_CTR(p, key, nonce) for p in ['SSBoYXZlIG1ldCB0aGVtIGF0IGNsb3NlIG9mIGRheQ==', 'Q29taW5nIHdpdGggdml2aWQgZmFjZXM=', 'RnJvbSBjb3VudGVyIG9yIGRlc2sgYW1vbmcgZ3JleQ==', 'RWlnaHRlZW50aC1jZW50dXJ5IGhvdXNlcy4=', 'SSBoYXZlIHBhc3NlZCB3aXRoIGEgbm9kIG9mIHRoZSBoZWFk', 'T3IgcG9saXRlIG1lYW5pbmdsZXNzIHdvcmRzLA==', 'T3IgaGF2ZSBsaW5nZXJlZCBhd2hpbGUgYW5kIHNhaWQ=', 'UG9saXRlIG1lYW5pbmdsZXNzIHdvcmRzLA==', 'QW5kIHRob3VnaHQgYmVmb3JlIEkgaGFkIGRvbmU=', 'T2YgYSBtb2NraW5nIHRhbGUgb3IgYSBnaWJl', 'VG8gcGxlYXNlIGEgY29tcGFuaW9u', 'QXJvdW5kIHRoZSBmaXJlIGF0IHRoZSBjbHViLA==', 'QmVpbmcgY2VydGFpbiB0aGF0IHRoZXkgYW5kIEk=', 'QnV0IGxpdmVkIHdoZXJlIG1vdGxleSBpcyB3b3JuOg==', 'QWxsIGNoYW5nZWQsIGNoYW5nZWQgdXR0ZXJseTo=', 'QSB0ZXJyaWJsZSBiZWF1dHkgaXMgYm9ybi4=', 'VGhhdCB3b21hbidzIGRheXMgd2VyZSBzcGVudA==', 'SW4gaWdub3JhbnQgZ29vZCB3aWxsLA==', 'SGVyIG5pZ2h0cyBpbiBhcmd1bWVudA==', 'VW50aWwgaGVyIHZvaWNlIGdyZXcgc2hyaWxsLg==', 'V2hhdCB2b2ljZSBtb3JlIHN3ZWV0IHRoYW4gaGVycw==', 'V2hlbiB5b3VuZyBhbmQgYmVhdXRpZnVsLA==',
#! /usr/bin/env python from AES_128 import gen_rand_data, AES_128_CTR, AES_128_CTR def get_unencrypted_data(): from AES_128 import AES_128_ECB_decrypt from binascii import a2b_base64 filename = '25.txt' key = 'YELLOW SUBMARINE' data = a2b_base64(''.join(l for l in open(filename))) return AES_128_ECB_decrypt(data, key, unpad=True) key = gen_rand_data() nonce = 0 def get_encrypted_data(): data = get_unencrypted_data() return AES_128_CTR(data, key, nonce) def edit(ciphertext, offset, newtext): data = AES_128_CTR(ciphertext, key, nonce) d = [c for c in data] newtext = [c for c in newtext] d[offset:offset + len(newtext)] = newtext data = ''.join(d) return AES_128_CTR(data, key, nonce)
def initialize(): global ciphertexts key = gen_rand_data() nonce = randint(0,2**64-1) ciphertexts = [AES_128_CTR(a2b_base64(p.strip()), key, nonce) for p in open('20.txt')]