https://github.com/adriank31/xor_encryption
A simple XOR-based encryption program written in C that allows users to obfuscate (encrypt) and de-obfuscate (decrypt) messages using a password as a key
https://github.com/adriank31/xor_encryption
decryption encryption xor-cipher xor-encryption
Last synced: 1 day ago
JSON representation
A simple XOR-based encryption program written in C that allows users to obfuscate (encrypt) and de-obfuscate (decrypt) messages using a password as a key
- Host: GitHub
- URL: https://github.com/adriank31/xor_encryption
- Owner: adriank31
- Created: 2025-02-03T03:11:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-03T03:47:44.000Z (over 1 year ago)
- Last Synced: 2025-02-28T17:46:47.723Z (over 1 year ago)
- Topics: decryption, encryption, xor-cipher, xor-encryption
- Language: C
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Overview
This is a simple XOR-based encryption program written in C that allows users to obfuscate (encrypt) and de-obfuscate (decrypt) messages using a password as a key.
The program demonstrates a rolling XOR cipher, where each character of the input message is XOR'd with a corresponding character of the user-provided password.
# Features
Accepts a password from the user (maximum 50 characters) as the encryption key.
Accepts a message from the user (maximum 500 characters) to be encrypted.
Applies XOR encryption to the message using the password.
Displays the message in HEX format before and after encryption for debugging purposes.
Decrypts the message by applying the XOR function again, proving that XOR is reversible.
Ensures safe input handling and prevents empty inputs.
# How It Works
The user enters a password (up to 50 characters) that acts as the encryption key.
The user inputs a message (up to 500 characters) to be encrypted.
The program converts the original message into a HEX representation for debugging.
The program applies the XOR encryption (mangling) process and displays the obfuscated message.
The obfuscated message is converted to HEX output for debugging.
The program decrypts the message by applying XOR again, restoring the original message.
The decrypted message is displayed in HEX to confirm that encryption and decryption worked correctly.
# Compilation and Execution
Compile the Program and use GCC or any C compiler to compile the program:

# Run the Program

# Example Usage
Enter your password (Limit is 50 characters): mysecretkey
Enter your message: Hello, XOR Encryption!
Original: Hello, XOR Encryption!
Original Message in HEX output: 48 65 6C 6C 6F 2C 20 58 4F 52 20 45 6E 63 72 79 70 74 69 6F 6E 21
Mangling (Obfuscated): %∟▼ ♀^E,$7Y(↨►↨→☻◄↔♦♂X
Manging Obfuscated Message in HEX output: 1A 4F 23 56 0F 32 79 14 6D 51 2A 64 39 50 1E 48 5F 3C 26 12 7F
Demangling (Original): Hello, XOR Encryption!
Decrypted Message in HEX output: 48 65 6C 6C 6F 2C 20 58 4F 52 20 45 6E 63 72 79 70 74 69 6F 6E 21
# Security Considerations
This program does not use cryptographic best practices. XOR encryption is not secure for sensitive data as it is vulnerable to frequency analysis and known-plaintext attacks.
The program does not use a cryptographic hash or key derivation function (KDF).
If the password is weak, brute-force attacks can easily reveal the original message.
For stronger encryption, consider using AES-256 or HMAC-SHA256 instead of XOR.
# Possible Improvements
Use a cryptographic hash (SHA-256) of the password to derive a strong key.
Introduce a salt to prevent predictable encryption.
Implement AES-256 encryption instead of XOR.
Add Base64 encoding for readable encrypted messages.
# License
This project is licensed under the MIT License. Feel free to use and modify the code for educational purposes.
# Author
Created by Adrian Korwel. Feel free to contribute to this project by submitting pull requests!