Skip to content

[FEATURE] XOR encryption mode (half-XOR with key file) #13

@djdarcy

Description

@djdarcy

Summary

Add an XOR encryption/decryption mode where one file is XORed with another (key file), modifying only the target file.

Background

The current XOR swap modifies BOTH files (content exchange). But XOR has another use case: simple symmetric encryption.

Proposed Feature

# Encrypt: XOR target with key, overwrites target
xmv secret.txt keyfile.bin --xor-with

# Decrypt: Same operation (XOR is symmetric)
xmv secret.txt.enc keyfile.bin --xor-with

How It Works

plaintext  XOR  key  =  ciphertext
ciphertext XOR  key  =  plaintext

Only the first file is modified. The key file remains unchanged.

Use Cases

  1. Simple obfuscation: Hide file contents with a key
  2. One-time pad: If key is random and >= file size, theoretically unbreakable
  3. Educational: Demonstrate XOR encryption concepts
  4. CTF challenges: Create/solve XOR-based puzzles

Implementation Notes

  • Only first file is modified
  • Key file must be readable but isn't changed
  • If key is shorter than target, could repeat (less secure) or error
  • --verify should still work (hash before/after)

CLI Options

--xor-with          # XOR first file with second (key)
--xor-repeat        # Repeat key if shorter than target (less secure)
--xor-truncate      # Only XOR up to key length, leave rest unchanged

Security Warning

This is NOT a secure encryption method for sensitive data. It's useful for:

  • Obfuscation
  • Educational purposes
  • One-time pad (if key is truly random and used once)

For real encryption, use proper tools (GPG, age, etc.).

Related

  • Core XOR swap functionality
  • Could integrate with --dry-run to preview operation

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfutureFuture considerationhelp wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions