The Hardware Side of Cryptography

26 March 2008

The Implementation of Vigenere Cipher on PIC16F84

Filed under: encryption — Tags: , , , — edipermadi @ 10:09 pm

Today, i was reading the “CRYPTOLOGIA History” book. I found nice classical cipher named “vigenere”. This cipher was invented by Blaise de Vigenère. Although this cipher is insecure, lets just code it for the sake of curiosity.

This post is dedicated to provide an example to anyone who is looking for the implementation of Vigenère cipher in hardware, especially on PIC16F84 the PICmicro Microcontroller from microchip. Hopefully this piece will benefit to anyone, at least to satisfy myself😀 .

This cipher mechanism is based on substitution table. The substitution table consisted of columns and rows labelled “A” to “Z”. To get cipher test, first you select the column of plain text and then you select the row of key. The intersection of row of column is called cipher text then. To decode cipher text, you select the row of key and you find the intersection which is equal to cipher text, the label of column is called plain text then. Simple right🙂 .

Vigenere Cipher Substitution Table

Above is the substitution table of vigenere cipher. I also took the screenshot of testing the algoritm on MPLAB 8. The picture is below:

Enciphering / Encoding Screenshot

Vigenere Cipher Enciphering Screenshot on MPLAB 8

Deciphering / Decoding Screenshot

Vigenere Cipher Deciphering Screenshot on MPLAB 8

Cheers :)

BENCHMARK

Test Vector

Encryption:

Plain Text : I AM TRYING TO HIDE THIS MESSAGE FOR YOU
Key: HOPEFULLY NOBODY COULD READ THIS TEXT
Cipher Text: POBXWSTYEGCIWGCVVCDPVWSDZLNGKCLN

Decryption:

Cipher Text: POBXWSTYEGCIWGCVVCDPVWSDZLNGKCLN
Key: HOPEFULLY NOBODY COULD READ THIS TEXT
Plain Text: I AM TRYING TO HIDE THIS MESSAGE FOR YOU

Speed Test:

Encryption : 870 cycles / 32 characters
Decryption : 902 cycles / 32 characters

RELATED STUFF

Download
Source Code | v1.0 | v1.1
PIC16F84 Datasheet
Mid-Range Reference Manual

References:
Vigenère Cipher

Official Website:
Microchip

Simulator
Vigenere Cipher Simulator

6 Comments »

  1. I would like to implement this algorithm using the Atmega32, it is possible? Could you give me some suggestions? Thanks very much!

    Comment by Abraão — 22 September 2010 @ 1:09 am

    • hi.
      thank you for visiting my blog. basically vigenere cipher is very simple and you can make it on C or assembly easily. the idea is like this:

      convert input and key to 0 – 25, say M1, C1 and K1 for plain text, cipher text and key.

      C1 = (M1 + K1) mod 26
      M1 = (C1 + K1) mod 26

      the implementation would be easy in both assembly and C. since the concept is about modular addition.

      good luck

      Comment by edipermadi — 22 September 2010 @ 1:19 pm

    • I’ve implemented vigenere in Java and placed it on my blog🙂 May it will help you!

      Comment by generalvlad86 — 19 November 2010 @ 2:22 pm

      • Thanks very much! It’s very interesting.

        Comment by Abraaão — 22 November 2010 @ 4:42 pm

      • Hi. thank you for visiting my blog

        Comment by edipermadi — 22 November 2010 @ 6:10 pm

  2. I implemented it using Java here: https://sourceforge.net/projects/encrypto/?source=updater

    Comment by Encrypto — 19 December 2012 @ 6:08 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: