for c in cipherText[len(cipherText) - loc:]:
            if chr((ord(c) ^ i)) == "A":
                return i, j
            j += 1


def Trace(val, index, cipherText):
    forward = cipherText[index + 1:]
    plainText = chr(ord(cipherText[index]) ^ val)
    for c in forward:
        orig = un.unTwist8(val)
        next = rnd.getNext8(orig, index)
        val = rnd.getTwist(next)
        index += 1
        plainText += chr((ord(c) ^ val))
    back = cipherText[0:index]
    return plainText


print rnd.getFirst8(1700000)

exit()
known = "A" * 14
num = random.randrange(1, 10)
unknown = os.urandom(num)
Message = unknown + known
seed = random.randrange(2**16, 2**17 - 1)
cipherText = encrypt(Message, seed)

rand, index = findAByte("A", cipherText, 14)
print Trace(rand, index, cipherText)
            if chr((ord(c) ^ i)) == "A":
                return i, j
            j += 1


def Trace(val, index, cipherText):
    forward = cipherText[index + 1 :]
    plainText = chr(ord(cipherText[index]) ^ val)
    for c in forward:
        orig = un.unTwist8(val)
        next = rnd.getNext8(orig, index)
        val = rnd.getTwist(next)
        index += 1
        plainText += chr((ord(c) ^ val))
    back = cipherText[0:index]
    return plainText


print rnd.getFirst8(1700000)

exit()
known = "A" * 14
num = random.randrange(1, 10)
unknown = os.urandom(num)
Message = unknown + known
seed = random.randrange(2 ** 16, 2 ** 17 - 1)
cipherText = encrypt(Message, seed)

rand, index = findAByte("A", cipherText, 14)
print Trace(rand, index, cipherText)