X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=szyfrow%2Frailfence.py;fp=szyfrow%2Frailfence.py;h=741e3e2ad3d7bafddbb7d722c468c8103009cb4f;hb=b535d9d75e69cc395e8de28c99e38564655e5ac9;hp=ef3d266f5739ee129d125b5d1d239f57847185aa;hpb=f19a021eabb3222709b9d513839a14c01cfdfd38;p=szyfrow.git diff --git a/szyfrow/railfence.py b/szyfrow/railfence.py index ef3d266..741e3e2 100644 --- a/szyfrow/railfence.py +++ b/szyfrow/railfence.py @@ -1,3 +1,19 @@ +"""[Railfence transposition cipher](https://en.wikipedia.org/wiki/Rail_fence_cipher). + +Works by splitting the text into sections, then reading across them to +generate the rows in the cipher. The rows are then combined to form the +ciphertext. + +Example: the plaintext "hellotherefriends", with a height of four, written +out in the railfence as + h h i + etere* + lorfns + l e d +(with the * showing the one character to finish the last section). +Each 'section' is two columns, but unfolded. In the example, the first +section is 'hellot'. +""" import math from enum import Enum from itertools import starmap, zip_longest