Exemplo n.º 1
0
def ECB(data,key,mode):
    result=""
    keyarray = f_des.key_schedule(key)
    if mode == "1":
        for i in range(0,len(data),64):
            result+=f_des.DES(data[i:i+64],keyarray)
    else:
        for i in range(0,len(data),64):
            result+=f_des.de_DES(data[i:i+64],keyarray)

    return result
Exemplo n.º 2
0
def ECB(data, key, mode):
    result = ""
    keyarray = f_des.key_schedule(key)
    if mode == "1":
        for i in range(0, len(data), 64):
            result += f_des.DES(data[i:i + 64], keyarray)
    else:
        for i in range(0, len(data), 64):
            result += f_des.de_DES(data[i:i + 64], keyarray)

    return result
Exemplo n.º 3
0
def CBC(data,key,mode,iv):
    result=""
    keyarray = f_des.key_schedule(key)
    if mode == "1":
        for i in range(0,len(data),64):
            tmp = f_des.xor_func(data[i:i+64],iv)
            iv = f_des.DES(tmp,keyarray)
            result+=iv
    else:
        for i in range(0,len(data),64):
            tmp = f_des.de_DES(data[i:i+64],keyarray)
            result += f_des.xor_func(tmp,iv)
            iv = data[i:i+64]

    return result
Exemplo n.º 4
0
def CBC(data, key, mode, iv):
    result = ""
    keyarray = f_des.key_schedule(key)
    if mode == "1":
        for i in range(0, len(data), 64):
            tmp = f_des.xor_func(data[i:i + 64], iv)
            iv = f_des.DES(tmp, keyarray)
            result += iv
    else:
        for i in range(0, len(data), 64):
            tmp = f_des.de_DES(data[i:i + 64], keyarray)
            result += f_des.xor_func(tmp, iv)
            iv = data[i:i + 64]

    return result