MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / process_text

Method process_text

ciphers/hill_cipher.py:104–118  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 2

encryptMethod · 0.95
decryptMethod · 0.95

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected