| 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)) |