MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / decryptMessage

Function decryptMessage

ciphers/transposition_cipher.py:30–49  ·  view source on GitHub ↗

>>> decryptMessage(6, 'Hlia rDsahrij') 'Harshil Darji'

(key, message)

Source from the content-addressed store, hash-verified

28 return ''.join(cipherText)
29
30def decryptMessage(key, message):
31 """
32 >>> decryptMessage(6, 'Hlia rDsahrij')
33 'Harshil Darji'
34 """
35 numCols = math.ceil(len(message) / key)
36 numRows = key
37 numShadedBoxes = (numCols * numRows) - len(message)
38 plainText = [""] * numCols
39 col = 0; row = 0;
40
41 for symbol in message:
42 plainText[col] += symbol
43 col += 1
44
45 if (col == numCols) or (col == numCols - 1) and (row >= numRows - numShadedBoxes):
46 col = 0
47 row += 1
48
49 return "".join(plainText)
50
51if __name__ == '__main__':
52 import doctest

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected