Skip to content

jonan-burg/simple-file-encrypter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple File Encryptor (C)

A minimal command-line utility written in C that performs file encryption and decryption using a Caesar cipher (shift of 3).


Overview

This project demonstrates a basic implementation of file-based encryption.

  • Encrypts text using a Caesar cipher (+3 shift)
  • Decrypts text using a Caesar cipher (-3 shift)
  • Preserves uppercase and lowercase letters
  • Leaves non-alphabet characters unchanged

Project Structure

.
├── encrypt.c
├── encrypt.exe
├── data.txt
├── secret.txt
├── output.txt

Compilation

gcc encrypt.c -o encrypt

▶️ Usage

./encrypt <mode> <inputfile> <outputfile>

Arguments

Argument Description
mode E for encryption, D for decryption
inputfile Path to the input file
outputfile Path to the output file

Examples

Encrypt

./encrypt E data.txt secret.txt

Decrypt

./encrypt D secret.txt output.txt

Example

Input (data.txt)

Hello! My name is Johan.

Encrypted (secret.txt)

Khoor! Pb qdph lv Mrkdq.

Decrypted (output.txt)

Hello! My name is Johan.

How It Works

The program reads the file character-by-character and applies transformations:

  • Uppercase letters:

    • Encryption: (ch - 'A' + 3) % 26 + 'A'
    • Decryption: (ch - 'A' - 3 + 26) % 26 + 'A'
  • Lowercase letters:

    • Encryption: (ch - 'a' + 3) % 26 + 'a'
    • Decryption: (ch - 'a' - 3 + 26) % 26 + 'a'
  • Other characters are unchanged


Disclaimer

This project uses a Caesar cipher, which is not secure and is intended for educational purposes only.

Do not use this for protecting sensitive information.


Improvements

  • Add custom shift value
  • Support binary files
  • Add password-based encryption
  • Implement stronger algorithms (AES, XOR)
  • Improve error handling
  • Build a GUI

Author

Johan


About

A simple command-line file encryptor written in C that uses a Caesar cipher to encrypt and decrypt text files.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages