Playfair Encryption Program


This classic cipher was very popular in the 1900s. It was used by the British forces during the Second Boer War and World War I.

Basically how it works is that you use a passphrase to encrypt a message. Once it's encrypted, the message can only be decrypted by someone who knows the passphrase. Because this cipher predates computers, it is actually quite simple to encrypt/decrypt on paper. If you would like to know more about playfair, search online and you'll find tons of information.

I was inspired to write this program by a great website I came across randomly called programmingpraxis.com, which is a site that offers free weekly (sometimes daily) programming practise challenges. I strongly urge all programmers to check out that website and do the challenges to keep their skills sharp.

This release comes with full C++ source code, as well as 32 and 64-bit Linux binaries, 32 and 64-bit OSX binaries, and 32-bit windows binaries.

To use the binaries below, you need to run them from a console.

On Linux or OSX this is done by opening a terminal, going into the directory that the binary was downloaded to, and issuing the command: ./playfair
If you get an error telling you it's not executable, run the command:
chmod 755 playfair
If you want to install the binary so that you can run it as a regular command from anywhere on your system do this as root:
cp -a playfair /usr/bin

On windows, open a command prompt by running cmd.exe, then go into the directory that the binary was downloaded to, and issue the command: playfair
If you want to install the binary so that you can run it as a regular command from anywhere on your system copy-paste the .exe file into C:\Windows\System32. You might need Administrator permissions.

Before using this software, please read the LICENSE that it's bound by (and the disclaimer contained in the license). By compiling or running this software, you acknowledge your formal agreement to be bound by the terms of the license and disclaimer.

Files Available for Download

If you want to extract .tar.bz2 archives on windows, I recommend using a program called 7-Zip. It's completely free and open-source.

If you ever open a text file in notepad on windows, and the formatting looks all messed up, it's usually because the file has *nix line endings, and notepad doesn't deal with these line endings properly. If this is a problem that you experience, you can use a free program called notepad++ instead. It deals with foreign line endings properly.

If you need either of these programs, search for them online. They'll be the first ones that come up.


Usage Example

Encrypt:

$ playfair -v "my passphrase" "a secret message"

Letters used in passphrase:

abcdefghiklmnopqrstuvwxyz
1000100100010010110000010

Okay, this is your key:

    0 1 2 3 4
 
0   m y p a s 
1   h r e b c 
2   d f g i k 
3   l n o q t 
4   u v w x z 

This is your message diagram:

as   ec   re   tm   es   sa   ge                        
1    2    3    4    5    6    7    

Here are the coordinates of each diagram letter's position in the key.
The top-left corner of your key is 0,0 (row,column):

1.    0,3 0,4
2.    1,2 1,4
3.    1,1 1,2
4.    3,4 0,0
5.    1,2 0,4
6.    0,4 0,3
7.    2,2 1,2

This is your encrypted message:

smbheblscpmsog

Decrypt:

$ playfair -dv "my passphrase" "smbheblscpmsog"

Letters used in passphrase:

abcdefghiklmnopqrstuvwxyz
1000100100010010110000010

Okay, this is your key:

    0 1 2 3 4
 
0   m y p a s 
1   h r e b c 
2   d f g i k 
3   l n o q t 
4   u v w x z 

This is your message diagram:

sm   bh   eb   ls   cp   ms   og                        
1    2    3    4    5    6    7    

Here are the coordinates of each diagram letter's position in the key.
The top-left corner of your key is 0,0 (row,column):

1.    0,4 0,0
2.    1,3 1,0
3.    1,2 1,3
4.    3,0 0,4
5.    1,4 0,2
6.    0,0 0,4
7.    3,2 2,2

This is your decrypted message:

asecretmessage

There is a fun Bourne Shell script which accompanies this program (included in the .tar.bz2 release) called filepass.sh. It generates a playfair passphrase for you by pulling a chunk of binary out of a daily-updated picture slot on a popular website. The point of using this method is that you don't have to keep a copy of your passphrase anywhere, instead just give a copy of the script to the message recipient. Because no-one has a copy of the key, the message you send will expire after about 1 day (as soon as the picture slot gets updated on the website). Using this method, your passphrase gets generated by the internet media machine. This script can easily be adapted to use any part of any picture on any website. It could probably also be implemented as a windows-friendly batch file, but I leave that up to the reader to create as a challenge (because I'm lazy and I hate writing batch files).


Was this program useful? Toss me a few bucks if you're feeling generous.


Comments


Post a Comment

Display Name:
Email Address:
Subject:
Comment:

NOTE: Your email address will only be seen by the webmaster, and will not be used to send you anything. Your IP address will be logged, but not displayed publicly.


Reload Image
Code:




Go back to Code section


This page and the code and software that goes along with it are copyright © Defcronyke Webmaster 2011, The Eternal Void Network (excluding third-party headers, libraries, or other data). It may only be linked to with permission from the original author. If you provide reference to it anywhere, please give credit to the author. The licenses for any third-party headers, libraries, or other data that are used in this release can be found inside the licenses folder in the release.



Number of Unique Hits: 00002449
Privacy Policy