|
|
@ -23,15 +23,18 @@ def keyToIntTuple(key): |
|
|
|
def applyKeyToBlock(keyT, blockL): # function to apply a key to a block |
|
|
|
def applyKeyToBlock(keyT, blockL): # function to apply a key to a block |
|
|
|
blockDe = [""] * blockSize |
|
|
|
blockDe = [""] * blockSize |
|
|
|
if(in_mode == 0): |
|
|
|
if(in_mode == 0): |
|
|
|
|
|
|
|
print("Encrypting block: " + str(blockL) ) |
|
|
|
for i in range(blockSize): |
|
|
|
for i in range(blockSize): |
|
|
|
blockDe[i] = blockL[keyT[i]] # encrypting |
|
|
|
blockDe[i] = blockL[keyT[i]] # encrypting |
|
|
|
elif(in_mode == 1): |
|
|
|
elif(in_mode == 1): |
|
|
|
|
|
|
|
print("Decrypting block: " + str(blockL) ) |
|
|
|
for i in range(blockSize): |
|
|
|
for i in range(blockSize): |
|
|
|
blockDe[keyT[i]] = blockL[i] # decrypting |
|
|
|
blockDe[keyT[i]] = blockL[i] # decrypting |
|
|
|
|
|
|
|
|
|
|
|
return blockDe |
|
|
|
return blockDe |
|
|
|
|
|
|
|
|
|
|
|
def splitInput(inputL, n): |
|
|
|
def splitInput(inputL, n): |
|
|
|
|
|
|
|
print("Splitting input: " + str(n)) |
|
|
|
out = [] |
|
|
|
out = [] |
|
|
|
inputLen = len(inputL) |
|
|
|
inputLen = len(inputL) |
|
|
|
x = inputLen / float(n) |
|
|
|
x = inputLen / float(n) |
|
|
|