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

Method encrypt

ciphers/hill_cipher.py:92–104  ·  view source on GitHub ↗
(self, text)

Source from the content-addressed store, hash-verified

90 return ''.join(text)
91
92 def encrypt(self, text):
93 text = self.processText(text.upper())
94 encrypted = ''
95
96 for i in range(0, len(text) - self.break_key + 1, self.break_key):
97 batch = text[i:i+self.break_key]
98 batch_vec = list(map(self.replaceLetters, batch))
99 batch_vec = numpy.matrix([batch_vec]).T
100 batch_encrypted = self.modulus(self.encrypt_key.dot(batch_vec)).T.tolist()[0]
101 encrypted_batch = ''.join(list(map(self.replaceNumbers, batch_encrypted)))
102 encrypted += encrypted_batch
103
104 return encrypted
105
106 def makeDecryptKey(self):
107 det = round(numpy.linalg.det(self.encrypt_key))

Callers 1

mainFunction · 0.95

Calls 1

processTextMethod · 0.95

Tested by

no test coverage detected