Encode and decode the rail fence (zigzag) transposition cipher. Choose the number of rails. A classic puzzle and CTF cipher.
It is a transposition cipher: you write the message diagonally down and up across a set number of rails (rows), then read it off one row at a time. The letters are not changed, only reordered, which is what makes it a transposition rather than a substitution cipher.
More rails create a more complex zigzag and scramble the order more. Both sides must use the same number of rails: it is the key. With 2 rails it just splits odd and even positions.
No. With only a handful of possible rail counts it is trivial to break by trying each. It is used for puzzles, teaching and CTF challenges, not real security.