>>> hill_cipher = HillCipher(np.array([[2, 5], [1, 6]])) >>> hill_cipher.process_text('Testing Hill Cipher') 'TESTINGHILLCIPHERR' >>> hill_cipher.process_text('hello') 'HELLOO'
(self, text: str)
| 102 | raise ValueError(msg) |
| 103 | |
| 104 | def process_text(self, text: str) -> str: |
| 105 | """ |
| 106 | >>> hill_cipher = HillCipher(np.array([[2, 5], [1, 6]])) |
| 107 | >>> hill_cipher.process_text('Testing Hill Cipher') |
| 108 | 'TESTINGHILLCIPHERR' |
| 109 | >>> hill_cipher.process_text('hello') |
| 110 | 'HELLOO' |
| 111 | """ |
| 112 | chars = [char for char in text.upper() if char in self.key_string] |
| 113 | |
| 114 | last = chars[-1] |
| 115 | while len(chars) % self.break_key != 0: |
| 116 | chars.append(last) |
| 117 | |
| 118 | return "".join(chars) |
| 119 | |
| 120 | def encrypt(self, text: str) -> str: |
| 121 | """ |