The Hardware Side of Cryptography

22 April 2008

An Implementation of Base64 Encoder/Decoder using PIC16F84

Filed under: decoding, encoding — Tags: , , , , — edipermadi @ 10:24 pm

Base64 or Radix-64 encoding or ASCII armour or whatever you name it, is a process of transforming arbirtary binary input into printable character. Theoretically speaking, the 3 bytes ( 3 x 8-bit) of input is treated as a block that will be divided into 4 6-bit data. Each of 6-bit data then translated into printable character. The mapping is shown below:

However, this post will demonsrate you how to implement Base64 on hardware, especially on PIC16F84 microcontroller.

This implementation comes in two versions. First version is intended for size optimized application and second version is intended for speed optimized application. Each of version contain its own benefit and drawback. You may choose the one which is match to your purpose.

BENCHMARK

Below are two screenshot of Base64 simulation on MPLAB v8.0. The first one is belong to plain text that is going to be encoded. The second one is belong to decoded message. Encoded message is always approximately 33% longer than its original.

Original Message

Encoded Message

Test Vector:
Original Message : edi
Encoded Message : ZWRp

Speed Benchmark:

  • Speed Oriented
    – encoding : 18 cycles / character
    – decoding : 21 cycles / character
  • Size Oriented
    – encoding : 26 cycles / character
    – decoding : 1069 cycles / character

RELATED STUFF

Download:
Base-64 Size Optimized Source Code | v1.0
Base-64 Speed Optimized Source Code | v2.0 | v2.1
PIC16F84 Datasheet
Mid-Range Reference Manual
MPLAB v8.0

Reference:
Base64

1 Comment »

  1. I comment each time I like a post on a website or I have something to valuable
    to contribute to the conversation. It’s a result of the sincerness communicated in the article I browsed. And on this article An Implementation of Base64 Encoder/Decoder using PIC16F84 The Hardware Side of Cryptography. I was excited enough to post a comment🙂 I do have 2 questions for you if it’s okay.
    Could it be only me or do a few of these responses appear like coming from brain
    dead folks?😛 And, if you are posting at other places, I’d like to keep up with you. Would you list the complete urls of your shared pages like your linkedin profile, Facebook page or twitter feed?

    Comment by healthe trim buy one get one free — 15 February 2013 @ 1:27 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: