Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
vigenere(1)		     Manpage for vigenere		   vigenere(1)

NAME
       vigenere	- Vigenere cipher cryptography tool

SYNOPSIS
       vigenere	[-ht] [-o outputfile] -d|-e -s|cipherword message
       vigenere	[-ht] [-o outputfile] -d|-e -i inputfile -s|cipherword

DESCRIPTION
       vigenere	is an implementation of	the Vigenere cipher algorithm extended
       to the entire set of printable ASCII characters.

       Program Invocation: vigenere can	be invoked in the following two	forms:

       1st  Form:  When	 invoked with either the -d or -e option and two other
       non-option arguments, the first non-option argument will	 be  taken  as
       the  cipherword to use, whereas the second argument denotes the message
       to decrypt/encrypt. If upon invocation the -s option is also passed  to
       the  utility,  then  the	 user is asked to input	the cipherword via the
       command line. User input	will not be echoed. In this  case,  the	 first
       non-option command line argument	resembles the message.

       2nd  Form:  If  the  utility,  next  to being invoked with the -d or -e
       switch, also gets passed	the -i switch, which requires a	file  to  read
       from, then the first non-option argument	represents the cipherword, un-
       less overridden with the	-s switch.

OPTIONS
       -d, --decrypt
	      decrypt message or inputfile

       -e, --encrypt
	      encrypt message or inputfile

       -h, --help
	      print a help message and exit

       -i inputfile, --inputfile=inputfile
	      read from	inputfile

       -o outputfile, --outputfile=outputfile
	      write to outputfile

       -s, --secret-phrase
	      enter the	cipherphrase unechoed via the command line

       -t, --tabula-recta
	      print the	Tabula Recta to	stdout and exit

THEORY
       The  Vigenere cipher is a multi phase shift cipher, which works,	by en-
       crypting	each letter of an original message with	the corresponding let-
       ter of a	freely chosen cipherphrase. Consider the Tabula	Recta below.

       Tabula Recta:

	  | A B	C D E F	G H I J	K L M N	O P Q R	S T U V	W X Y Z
       ---------------------------------------------------------
	A | A B	C D E F	G H I J	K L M N	O P Q R	S T U V	W X Y Z
	B | B C	D E F G	H I J K	L M N O	P Q R S	T U V W	X Y Z A
	C | C D	E F G H	I J K L	M N O P	Q R S T	U V W X	Y Z A B
	D | E F	G H I J	K L M N	O P Q R	S T U V	W X Y Z	A B C C
	E | E F	G H I J	K L M N	O P Q R	S T U V	W X Y Z	A B C D
	F | F G	H I J K	L M N O	P Q R S	T U V W	X Y Z A	B C D E
	G | G H	I J K L	M N O P	Q R S T	U V W X	Y Z A B	C D E F
	H | H I	J K L M	N O P Q	R S T U	V W X Y	Z A B C	D E F G
	I | I J	K L M N	O P Q R	S T U V	W X Y Z	A B C D	E F G H
	J | J K	L M N O	P Q R S	T U V W	X Y Z A	B C D E	F G H I
	K | K L	M N O P	Q R S T	U V W X	Y Z A B	C D E F	G H I J
	L | L M	N O P Q	R S T U	V W X Y	Z A B C	D E F G	H I J K
	M | M N	O P Q R	S T U V	W X Y Z	A B C D	E F G H	I J K L
	N | N O	P Q R S	T U V W	X Y Z A	B C D E	F G H I	J K L M
	O | O P	Q R S T	U V W X	Y Z A B	C D E F	G H I J	K L M N
	P | P Q	R S T U	V W X Y	Z A B C	D E F G	H I J K	L M N O
	Q | Q R	S T U V	W X Y Z	A B C D	E F G H	I J K L	M N O P
	R | R S	T U V W	X Y Z A	B C D E	F G H I	J K L M	N O P Q
	S | S T	U V W X	Y Z A B	C D E F	G H I J	K L M N	O P Q R
	T | T U	V W X Y	Z A B C	D E F G	H I J K	L M N O	P Q R S
	U | U V	W X Y Z	A B C D	E F G H	I J K L	M N O P	Q R S T
	V | V W	X Y Z A	B C D E	F G H I	J K L M	N O P Q	R S T U
	W | W X	Y Z A B	C D E F	G H I J	K L M N	O P Q R	S T U V
	X | X Y	Z A B C	D E F G	H I J K	L M N O	P Q R S	T U V W
	Y | Y Z	A B C D	E F G H	I J K L	M N O P	Q R S T	U V W X
	Z | Z A	B C D E	F G H I	J K L M	N O P Q	R S T U	V W X Y

       Suppose now, that the message to	encrypt	is: SECRET MESSAGE TO ENCODE

       along with the cipherphrase: TULIP

       To encrypt a message, it	is first lined up with the cipherphrase,  let-
       ter  by	letter.	 If  the  cipherphrase	is shorter than	the message to
       transform, then it is simply repeated until every letter	of the message
       is covered.

       SECRET MESSAGE TO ENCODE
       TULIPT ULIPTUL IP TULIPT

       Actual encryption takes place, by finding the character,	 for  which  a
       pair  of	 corresponding	message- and cipherphrase letters intersect in
       the Tabula Recta. Whereas a message character is	looked up in the left-
       most column (message column), a cipherword letter is  searched  for  in
       the  topmost row	(cipherword row). Horizontal- and vertical lines drawn
       from the	characters positions on	these axes,  result  in	 the  encryped
       character.  When	performing these lookups for the above character pairs
       (coordinates), the encrypted message is:

       LYNZTM GPAHTAP BD XHNWSX

       To decrypt a message, knowledge of the cipherword is required. The  en-
       crypted	message	 is  aligned  with the cipherword as if	wanting	to en-
       crypt. However, instead of finding the point of intersection inside  of
       the  Tabula Recta, one now has to find the letters of the original mes-
       sage in the message column. This	is done, by first locating the cipher-
       sword's character of a given pair in the	cipherword row.	Once found,  a
       perpendicular  line is drawn downwards until the	pair's encrypted char-
       acter is	encountered inside the Tabula Recta. When now drawing a	 hori-
       zontal line to the left from this character, one	eventually reaches the
       decrypted  character  for  the pair in the message column. By following
       these steps, one	obtains	the original message for the encrypted message
       above:

       LYNZTM GPAHTAP BD XHNWSX
       TULIPT ULIPTUL IP TULIPT

       gives:

       SECRET MESSAGE TO ENCODE

       The traditional Vigenere	cipher only uses capital letters from A-Z,  as
       in  the	example	 above.	This implementation extends this notion	to the
       entire set of displayable ASCII characters (Hex 20 - Hex	7E).

       The Vigenere cipher is named after Blaise de Vigenere (1523 - 1596).

EXAMPLES
       1. Encrypt the message: "Hello world" with  the	cipherword  "213"  and
       write the result	to stdout.

       vigenere	-e 213 "Hello world"

       2.  Decrypt  the	message: (zo{u)Uyn$(vsnP)%Ln~w%pn using	the word TULIP
       as a cipherphrase.

       vigenere	-d TULIP '(zo{u)Uyn$(vsnP)%Ln~w%pn'

       3. Encrypt the contents of file:	~/message.txt and write	it  to:	 ~/en-
       crypted.txt. The	cipherphrase is	entered	via the	command	line.

       vigenere	-e -o ~/encrypted.txt -i ~/message.txt -s

AUTHOR
       Oliver Mahmoudi (contact@olivermahmoudi.com)

vigenere 1.0			   June	2020			   vigenere(1)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=vigenere&sektion=1&manpath=FreeBSD+Ports+15.0>

home | help