ciphers.rail_fence_cipher ========================= .. py:module:: ciphers.rail_fence_cipher .. autoapi-nested-parse:: https://en.wikipedia.org/wiki/Rail_fence_cipher Functions --------- .. autoapisummary:: ciphers.rail_fence_cipher.bruteforce ciphers.rail_fence_cipher.decrypt ciphers.rail_fence_cipher.encrypt Module Contents --------------- .. py:function:: bruteforce(input_string: str) -> dict[int, str] Uses decrypt function by guessing every key >>> bruteforce("HWe olordll")[4] 'Hello World' .. py:function:: decrypt(input_string: str, key: int) -> str Generates a template based on the key and fills it in with the characters of the input string and then reading it in a zigzag formation. >>> decrypt("HWe olordll", 4) 'Hello World' >>> decrypt("This is a message", -10) Traceback (most recent call last): ... ValueError: Height of grid can't be 0 or negative >>> decrypt("My key is very big", 100) 'My key is very big' .. py:function:: encrypt(input_string: str, key: int) -> str Shuffles the character of a string by placing each of them in a grid (the height is dependent on the key) in a zigzag formation and reading it left to right. >>> encrypt("Hello World", 4) 'HWe olordll' >>> encrypt("This is a message", 0) Traceback (most recent call last): ... ValueError: Height of grid can't be 0 or negative >>> encrypt(b"This is a byte string", 5) Traceback (most recent call last): ... TypeError: sequence item 0: expected str instance, int found