MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / hill_cipher

Function hill_cipher

projects/hill_cipher/decryption.py:17–33  ·  view source on GitHub ↗
(text, key_matrix)

Source from the content-addressed store, hash-verified

15
16
17def hill_cipher(text, key_matrix):
18 cipher_text = []
19 sum = 0
20 for i in range(3):
21 sum += (text[i] - 1) * key_matrix[i]
22 cipher_text.append(sum)
23
24 sum = 0
25 for i in range(3, 6):
26 sum += (text[i - 3] - 1) * key_matrix[i]
27 cipher_text.append(sum)
28
29 sum = 0
30 for i in range(6, 9):
31 sum += (text[i - 6] - 1) * key_matrix[i]
32 cipher_text.append(sum)
33 return cipher_text
34
35
36def message(actual_text):

Callers 1

messageFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected