Пример #1
0
def test1():
    outedges,walldomains,varsaffectedatwall=tc.test1()
    wallinfo = wl.makeWallInfo(outedges,walldomains,varsaffectedatwall)
    print wallinfo[(0,1)]==[(3,('um',))]
    print wallinfo[(1,3)]==[(2,('Mu',))]
    print wallinfo[(3,2)]==[(0,('dM',))]
    print wallinfo[(2,0)]==[(1,('md',))]
Пример #2
0
def test1():
    outedges, walldomains, varsaffectedatwall = tc.test1()
    wallinfo = wl.makeWallInfo(outedges, walldomains, varsaffectedatwall)
    print wallinfo[(0, 1)] == [(3, ('um', ))]
    print wallinfo[(1, 3)] == [(2, ('Mu', ))]
    print wallinfo[(3, 2)] == [(0, ('dM', ))]
    print wallinfo[(2, 0)] == [(1, ('md', ))]
Пример #3
0
def test1(showme=1, findallmatches=1):
    wallinfo = makeWallInfo(*tc.test1())

    pattern = ["md", "um", "Mu", "dM", "md"]
    match = matchPattern(pattern, wallinfo, cyclic=1, findallmatches=findallmatches)
    if showme:
        print match == [(0, 1, 3, 2, 0)]

    pattern = ["md", "um", "Mu", "dM", "Md"]  # 'Md' DNE in graph
    match = matchPattern(pattern, wallinfo, cyclic=0, findallmatches=findallmatches)
    if showme:
        print "None" in match

    pattern = ["md", "Mu", "dM", "md"]  # intermediate extrema
    match = matchPattern(pattern, wallinfo, cyclic=1, findallmatches=findallmatches)
    if showme:
        print "None" in match
Пример #4
0
def test1(showme=1, findallmatches=1):
    wallinfo = makeWallInfo(*tc.test1())

    pattern = ['md', 'um', 'Mu', 'dM', 'md']
    match = matchPattern(pattern,
                         wallinfo,
                         cyclic=1,
                         findallmatches=findallmatches)
    if showme: print match == [(0, 1, 3, 2, 0)]

    pattern = ['md', 'um', 'Mu', 'dM', 'Md']  # 'Md' DNE in graph
    match = matchPattern(pattern,
                         wallinfo,
                         cyclic=0,
                         findallmatches=findallmatches)
    if showme: print 'None' in match

    pattern = ['md', 'Mu', 'dM', 'md']  # intermediate extrema
    match = matchPattern(pattern,
                         wallinfo,
                         cyclic=1,
                         findallmatches=findallmatches)
    if showme: print 'None' in match
Пример #5
0
def blockify(input_bin_str, block_len):
    return [
        input_bin_str[i:i + block_len]
        for i in range(0, len(input_bin_str), block_len)
    ]


def cbc_decrypt(cipher, input_bin_str, iv, block_len):
    # Function for decrypting a single block
    def decrypt_block(cipher, enc_str, iv):
        return strxor(cipher.decrypt(enc_str), iv)

    output_str = ""
    block_list = blockify(input_bin_str, block_len)

    next_iv = iv
    for block in block_list:
        output_str += decrypt_block(cipher, block, next_iv)
        next_iv = block

    return output_str


if __name__ == "__main__":
    testcases.test1()
    testcases.test2()
    testcases.test3()
    testcases.test4()
    testcases.test5a()
    testcases.test5b()