Triple DES Algorithm C Program

By | August 8, 2017

Let us understand the Triple Data Encryption Standard encryption algorithm and then let’s implement Triple DES algorithm in C programming using OpenSSL header file.

What is Triple DES Algorithm?

The Triple DES algorithm is also popularly known as TDEA which is an abbreviation for Triple Data Encryption Algorithm.

It is basically a block-cipher method that applies the simple DES algorithm thrice to every single data block present in the input.

Initially, the key size was 56-bit but it made the brute force attacks to be successful in some scenarios. Usually, the chances of successful hacking are difficult in longer keys.

C Program For Triple DES Algorithm with Explanation, Output and Code

The 3 DES algorithm focusses on increasing the number of keys to make it impossible for the attackers to crack it using brute force method. It, therefore, takes 3 keys of 64-bits each.


The keys are a total of 192-bits and the data is first encrypted by the first key. It is then, decrypted by the second key and then again decrypted with the third key.

The Triple Data Encryption Standard algorithm is much more powerful than the simple DES algorithm. However, it has a disadvantage that it runs really slow as comparatively.

Note: This Triple DES Algorithm in C programming is compiled with CodeLite IDE and GNU GCC compiler on Microsoft Windows 10 operating system.


C Program To Implement Triple DES Algorithm using OpenSSL

To implement the Triple DES Algorithm C code, you will have to install the des.h header file as it is not available in C library files by default. Alternatively, you can even create your own header files using this method.

Header File C Program for OpenSSL DES.h

For the above C program to execute properly, you will have to download des.h header file and install it in your operating system. Please check this des.h file.

If you have any compilation errors or doubts about this C program to encrypt data using Triple Data Encryption Standard Algorithm, let us discuss it in the comment section below.

For more information on Triple DES algorithm in cryptography, please check OpenSSL or Wikipedia.

Let's Discuss