Simple Encryption using C Programming Language

Welcome! As I have mentioned in the previous blog, we are here. If you haven't read the previous blog click here.

Have you ever wanted to play around with cryptography but felt overwhelmed by complex algorithms? Fear not! In this blog post, we'll learn an exciting yet simple encryption using a straightforward approach in C programming. Get ready to explore!


The Challenge:

Imagine you have two existing files, "Uppercase.txt" and "Lowercase.txt", each containing meaningful messages written in their respective cases.

if you dont know john doe you are not a real programmer
-Lowercase.txt

HELLO THERE MY NAME IS POND JAMES POND
-Uppercase.txt

Your challenge? To combine these messages in a unique way, creating a ciphered text that conceals the original meanings. It's a puzzle waiting to be solved, a challenge waiting to be conquered.


The Approach:

Our approach to this challenge is refreshingly simple yet effective. We'll use basic C programming techniques to alternate between the uppercase and lowercase messages, extracting random chunks from each and combining them to create our ciphered text. To add an extra layer of intrigue, we'll replace spaces in the uppercase message with underscores and spaces in the lowercase message with hyphens. This alternating and ciphering process will transform our ordinary messages into an enigmatic code ready for decryption.


The Solution:


  1. File Setup: We begin by declaring the file names for our input and output files.

  2. Randomization: We seed the random number generator and set a limit for the length of random chunks to extract from each message.

  3. File Handling: We open the input files for reading and the output file for appending, ensuring that any existing content in the output file is cleared.

  4. Text Retrieval: We read the content of both input files and store them in separate arrays.

  5. Chunking and Ciphering: Using a while loop, we alternate between the two input texts, extracting random chunks. Spaces in the uppercase text are replaced with underscores, while spaces in the lowercase text are replaced with hyphens. The chunks are then written to the output file alternatively inside the loop. In the file, everything combines to form a cipher text.

  6. File Closure: Finally, we close all the files, completing the encryption process.


The Revelation:

After running our encryption program, the once ordinary messages transform into mysterious ciphered texts. The hidden meanings lie concealed within the code, waiting to be deciphered by the existing code we made in previous blog.


Thank You, and Happy Problem Solving!             o(*^▽^*)┛


Comments

Popular posts from this blog

Separating Letters by Cases in C - Awesome Implementation