示例#1
0
文件: prob6.py 项目: Han0nly/crypto
def findKey(split):
    bestMg = 0.0
    bestKey = 0
    for i in range(256):
        mg, plain = tryKey(rawToHex(split), rawToHexLUT[i])
        if (mg > bestMg):
            bestMg = mg
            bestKey = i
    return chr(bestKey)
def findKey(split):
    bestMg = 0.0;
    bestKey = 0;
    for i in range(256):
        mg, plain = tryKey(rawToHex(split), rawToHexLUT[i]);
        if (mg > bestMg):
            bestMg = mg;
            bestKey = i;
    return chr(bestKey);
示例#3
0
def findSingleCharXOR(ciphers):
    for cip in ciphers:
        for i in range(256):
            mg, plain = tryKey(cip, rawToHexLUT[i]);
            if (mg > .050):
                print("potential key: 0x" + rawToHexLUT[i]);
                print("potential hex(cipher): " + str(cip).lstrip("b'").rstrip("'"));
                print("potential hex(plain): " + str(plain).lstrip("b'").rstrip("'"));
                print("potential plaintext: " + str(hexToRaw(str(plain).lstrip("b'").rstrip("'"))).lstrip("b'").rstrip("'"));
示例#4
0
文件: prob4.py 项目: Han0nly/crypto
def findSingleCharXOR(ciphers):
    for cip in ciphers:
        for i in range(256):
            mg, plain = tryKey(cip, rawToHexLUT[i])
            if (mg > .050):
                print("potential key: 0x" + rawToHexLUT[i])
                print("potential hex(cipher): " +
                      str(cip).lstrip("b'").rstrip("'"))
                print("potential hex(plain): " +
                      str(plain).lstrip("b'").rstrip("'"))
                print("potential plaintext: " +
                      str(hexToRaw(str(plain).lstrip("b'").rstrip(
                          "'"))).lstrip("b'").rstrip("'"))