Пример #1
0
def findxoredstring(cyphertext: list[bytes]) -> bytes:
    candidates = []
    for line in cyphertext:
        line = break_single_byte_xor(line)
        if line:
            candidates.append(line)
    return mostprobable(candidates)
Пример #2
0
def findxoredstring(cyphertext):
    candidates = []
    for line in cyphertext:
        line = break_single_byte_xor(line)
        #if line != None:
        candidates.append(line)
    return mostprobable(candidates)
Пример #3
0
def key(cyphertext):
    keysize = findkeysize(cyphertext)
    blocks = [cyphertext[i:i + keysize] for i in range(0, len(cyphertext), keysize)]
    blocks = [bytes(x) for x in list(zip(*blocks[0:-1]))]
    cleartext = bytes([m03.break_single_byte_xor(x)[0] for x in blocks])
    key = m02.fixed_xor(cleartext, cyphertext)
    return key
Пример #4
0
def key(cyphertext: bytes) -> bytes:
    keysize = find_keysize(cyphertext)
    blocks = [
        cyphertext[i:i + keysize] for i in range(0, len(cyphertext), keysize)
    ]
    blocks = [bytes(x) for x in zip(*blocks[0:-1], strict=True)]
    plaintext = bytes([break_single_byte_xor(x)[0] for x in blocks])
    return fixed_xor(plaintext, cyphertext[:len(plaintext)])
Пример #5
0
def single_byte_xor_key(c: list[bytes]) -> bytes:
    c_t = transpose_bytes(c)
    return bytes([fixed_xor(break_single_byte_xor(x), x)[0] for x in c_t])
Пример #6
0
def single_byte_xor_key(c):
    c_T = transpose_bytes(c)
    return bytes([fixed_xor(break_single_byte_xor(x), x)[0] for x in c_T])