The Data Encryption Standard (DES) is a symmetric-key algorithm for the encryption of electronic data. Although now considered insecure, it was highly influential in the advancement of modern cryptography.

This article does not cover an overview of the DES Algorithm. We suggest going through the very nice tutorial given here for a detailed step-by-step explanation.

Input files to the program:

input.txt – Will contain our plain text (Max. Limit of plain text is 64kb).
key.txt – Will contain 64-bit key (Take the following key)
 
0001001100110100010101110111100110011011101111001101111111110001

DES Implementation:


OUTPUT FILE:
 
result.txt – IT WILL CONTAIN OUR DECRYPTED TEXT.
 
TEMP FILES:
 
bits.txt – IT WILL CONTAIN OUR PLAIN TEXT CONVERTED IN BITS.
cipher.txt – IT WILL CONTAIN OUR ENCRYPTED TEXT IN BITS.
decrypted.txt – IT WILL CONTAIN OUR DECRYPTED TEXT IN BITS (SAME AS bits.txt IN CONTENT)

 
The above program is tested in the Windows environment using Code::Blocks 16.01.

That’s all about DES implementation in C.

 
Exercise: Extend the solution to implement 3-DES algorithm.