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

Method makeDecryptKey

ciphers/hill_cipher.py:106–120  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

104 return encrypted
105
106 def makeDecryptKey(self):
107 det = round(numpy.linalg.det(self.encrypt_key))
108
109 if det < 0:
110 det = det % len(self.key_string)
111 det_inv = None
112 for i in range(len(self.key_string)):
113 if (det * i) % len(self.key_string) == 1:
114 det_inv = i
115 break
116
117 inv_key = det_inv * numpy.linalg.det(self.encrypt_key) *\
118 numpy.linalg.inv(self.encrypt_key)
119
120 return self.toInt(self.modulus(inv_key))
121
122 def decrypt(self, text):
123 self.decrypt_key = self.makeDecryptKey()

Callers 1

decryptMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected