**Topic :**Base64 Bit Encryption Tutorial

**Author :**Ilia Yordanov

**Page :**

**1**

**The Base 64 bit encryption**

Ilia Yordanov

Ilia Yordanov

Version 1.0, Last Updated: 24 September 2001

**I.Legal**This tutorial is written by Ilia Yordanov, and can't be re-published without a written permission from the author!

If you want to contact me, mail me at: loobian@cpp-home.com

**II.Assuming...**I am not assuming that you know C++, but it will be of help! Generally, the algorithm that I will explain can be implemented and ran in any language. Anyway, all the code examples are in C++...

**III.About the author...**My name is Ilia Yordanov. Me and Deyan Vitanov are the owners of www.cpp-home.com!

__Contact Information:__

E-mail: loobian@cpp-home.com

ICQ: 52958267

URL: http://www.cpp-home.com

If you have any suggestions, recommendations and so on, on how to improve this tutorial, please email me!

**IV.Introduction**This algorithm doesn't provide secure encryption method... and its purpose is not to teach you how to protect your data... it is for those who want to see how an example chiper works, and to train their knowledge!

Also, I am not respoinsible for any damages that may cause.

**BASE 64 BIT Encryption**

**1.Get the decimal value**

Now, let imagine that you have the word "Hello" that you want to encrypt. As you probably know, every letter from the alphabet has it's uniquee number in the ASCII table /in decimal value/. If you want to get the number of a letter, just type:

char letter;

letter='m';

cout << int(letter)<<endl;

This will output "109" on the screen. 109 is the decimal value of "m".

So, the first thing from the encrypting process is to convert every letter into it's decimal value. For example, you have an array /static/ like this:

char word[6]="Hello";

Now, you should convert every letter to it's decimal value. Here is an example:

char word[6]="Hello";

int decimal[6];

for(int a=0;a<6;a++)

decimal[a]=int(word[a]);

**2.Convert to binary**

After you have the decimal value of every letter, you should convert it to it's binary value. For example 0011 in binary, is 3 in decimal. Remember, that every single decimal value must be 8 bits in binary value.

So, if we have decimal value of 3, we should have this as binary: 00000011

I am not going to show you how to make the convertion from decimal to binary, as it is out of the purpose of this tutorial... you can find algorithms and code on this topic at www.cpp-home.com

**3.Splitting**

Now, imagine that you have the word "Hello" /as mentioned before/. This word should look this way in decimal:

*H= 72*

e= 101

l= 108

l= 108

o= 111

e= 101

l= 108

l= 108

o= 111

So, after all, "Hello" is 72 101 108 108 111. Now, this converted into binary should look like this:

*72= 01001000*

101= 01100101

108= 01101100

108= 01101100

111= 01101111

101= 01100101

108= 01101100

108= 01101100

111= 01101111

After all, it should look like this:

*01001000 01100101 01101100 01101100 01101111*

Now, when you connect it, it looks like this:

*0100100001100101011011000110110001101111*

As said before, every decimal value must be converted into 8 bit binary value. "Hello" has 5 letters, so in binary it should have 5*8 digits number. And in fact it is so- 40 bits.

Now, the next step is to divide this 40bit number on every 6 bits, like this:

*010010 000110 010101 101100 011011 000110 1111*

After that, you should convert every 6 bit number into it's decimal value. After you do it, it should look like this:

*18 6 21 44 27 6 15*

**4.Get the letter...**

After you have the new decimal numbers, you should display the letter that is assigned to every number.

This loop will do that: /note that I use static array, just for this example/

int decimals[7]={18,6,21,44,27,6,15};

char new_letters[7];

for(int c=0;c<7;c++)

new_letters[c]=char(decimals[c]);

cout << endl;

Now, in the array "new_letters" you have the letter from every number.

**5.Decrypting...**

If you want to decrypt the string, just make all that in the opposite order...

Please, feel free to contact me, with suggestions and whatelse, at

*loobian@cpp-home.com*

Copyright © 2001! All rights reserved!

**Page :**

**1**