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

Method checkDeterminant

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

Source from the content-addressed store, hash-verified

70 self.break_key = encrypt_key.shape[0]
71
72 def checkDeterminant(self):
73 det = round(numpy.linalg.det(self.encrypt_key))
74
75 if det < 0:
76 det = det % len(self.key_string)
77
78 req_l = len(self.key_string)
79 if gcd(det, len(self.key_string)) != 1:
80 raise ValueError("discriminant modular {0} of encryption key({1}) is not co prime w.r.t {2}.\nTry another key.".format(req_l, det, req_l))
81
82 def processText(self, text):
83 text = list(text.upper())

Callers 1

__init__Method · 0.95

Calls 1

gcdFunction · 0.70

Tested by

no test coverage detected