예제 #1
0
파일: m04.py 프로젝트: fionn/cryptopals
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
파일: m04.py 프로젝트: iamfionn/matasano
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
파일: m06.py 프로젝트: iamfionn/matasano
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
파일: m20.py 프로젝트: fionn/cryptopals
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
파일: m20.py 프로젝트: iamfionn/matasano
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])