/vernam

Vernam Cipher encoder/decoder

Primary LanguageCGNU General Public License v3.0GPL-3.0

vernam

Vernam Cipher encoder/decoder

Installation

make && sudo make install

Usage

Usage: ./vernam [--help] [--table] [--row <row>] [--pad <pad>]
                [--key <key>] [--cipher <cipher>] [--text <text>]
Flag Notes
--help Display above usage message
--table Generates/displays the cipher table
--row <row> Starting row (26 characters) of the cipher table
--pad <pad> Increment by row (can be positive or negative)
--key <key> Secret key used to encode/decode
--cipher <cipher> Message to decode
--text <text> Message to encode

Example

Table display for manual encoding/decoding

./vernam --row zyxwvutsrqponmlkjihgfedcba --pad -1 --table

Output:

 ABCDEFGHIJKLMNOPQRSTUVWXYZ
Azyxwvutsrqponmlkjihgfedcba
Byxwvutsrqponmlkjihgfedcbaz
Cxwvutsrqponmlkjihgfedcbazy
Dwvutsrqponmlkjihgfedcbazyx
Evutsrqponmlkjihgfedcbazyxw
Futsrqponmlkjihgfedcbazyxwv
Gtsrqponmlkjihgfedcbazyxwvu
Hsrqponmlkjihgfedcbazyxwvut
Irqponmlkjihgfedcbazyxwvuts
Jqponmlkjihgfedcbazyxwvutsr
Kponmlkjihgfedcbazyxwvutsrq
Lonmlkjihgfedcbazyxwvutsrqp
Mnmlkjihgfedcbazyxwvutsrqpo
Nmlkjihgfedcbazyxwvutsrqpon
Olkjihgfedcbazyxwvutsrqponm
Pkjihgfedcbazyxwvutsrqponml
Qjihgfedcbazyxwvutsrqponmlk
Rihgfedcbazyxwvutsrqponmlkj
Shgfedcbazyxwvutsrqponmlkji
Tgfedcbazyxwvutsrqponmlkjih
Ufedcbazyxwvutsrqponmlkjihg
Vedcbazyxwvutsrqponmlkjihgf
Wdcbazyxwvutsrqponmlkjihgfe
Xcbazyxwvutsrqponmlkjihgfed
Ybazyxwvutsrqponmlkjihgfedc
Zazyxwvutsrqponmlkjihgfedcb

Encode a message

./vernam --row zyxwvutsrqponmlkjihgfedcba --pad -1 --key test --text attackatdawn

Output:

gcogelhndvlt

Decode a message

./vernam --row zyxwvutsrqponmlkjihgfedcba --pad -1 --key test --text gcogelhndvlt

Output:

attackatdawn

Explanation

Read more about the Gilbert Vernam and his cipher (one-time pad).