Skip to content

A simple XOR-based plaintext encryptor using basic mathematical concepts of XOR to encrypt plaintext using a custom or random key based on user input.

License

Notifications You must be signed in to change notification settings

HKTITAN/XORencryptor

Repository files navigation

XOR-Based Text Encryption/Decryption in Python

This Python script implements a simple XOR-based encryption and decryption algorithm for text data. It provides functionalities for both encrypting plaintext messages and decrypting previously encrypted text using a user-defined key.

Learn More: https://youtu.be/QqiFrOG-IvU?si=JqLvjH_X4Mcrz1au

Features

Encrypt and decrypt text messages using XOR operation. Generate random keys for encryption or use user-provided keys. Display detailed encryption/decryption steps for educational purposes.

Usage

Clone this repository or download the script. Open a terminal window and navigate to the script's directory. Run the script using python xor_cipher.py. Follow the prompts to select encryption or decryption, provide the plaintext/ciphertext, and optionally enter a key.

Example

Encrypt a message:

Select an option:

  1. Encrypt
  2. Decrypt Enter 1 or 2: 1

Enter plaintext: This is a secret message! Enter key (press Enter for random key): secret_key

Key: secret_key

Encryption Steps:

Character ASCII Binary Plain Binary Key XOR Result Hex
T 84 01010100 11100100 10110000 d0
h 104 01101000 11100100 00001100 0c
i 105 01101001 11100100 00001101 0d
s 115 01110011 11100100 00010111 1f
... (remaining characters) ...

Encrypted Text: d00c0d1f... (truncated)

Decrypt a message (using the same key):

Select an option:

  1. Encrypt
  2. Decrypt Enter 1 or 2: 2

Enter the decryption key: secret_key Enter the encrypted text: d00c0d1f... (truncated)

Decryption Key: secret_key

Decryption Steps:

Hex Value Binary Plain Binary Key XOR Result Character ASCII
d0 01010100 11100100 10110000 T 84
0c 00001100 11100100 11100000 h 104
0d 00001101 11100100 11100001 i 105
1f 00010111 11100100 11110011 s 115
... (remaining characters) ...

Decrypted Text: This is a secret message!

About

A simple XOR-based plaintext encryptor using basic mathematical concepts of XOR to encrypt plaintext using a custom or random key based on user input.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages