Skip to main content

BaseX64: A simple cryptographic tool for storing data in distributed version control systems like Git.

Project description

BaseX64

What is it?

The BaseX64 script is a simple cryptographic tool that uses dynamic XOR for encryption, combined with a Base64-like encoding scheme, ensuring that only printable ASCII characters are used. Additionally, it supports line-by-line ciphering, which ensures that only the corresponding lines in the ciphertext are updated after changes in the original data and re-encryption.

Why reinvent the wheel? I needed a Python tool that would allow storing encrypted data on distributed version control systems such as Git, while meeting the following criteria:

  • Using only ASCII characters.
  • Ensuring that small changes in the source do not cause a total change in the ciphertext.

While AES-CTR could fulfill these requirements, Python does not have native AES support in its standard library. To avoid relying on third-party libraries, I decided to implement a custom solution.

Main features

  • Encrypt and decrypt files using a Base64-like scheme with dynamic XOR shifts.
  • Customizable initialization vector (IV) length and divided store mode.
  • Handling for both inline data and file input/output.
  • Ability to handle IV-based dynamic shifts for encryption/decryption.
  • Command-line interface (CLI) for simple usage.

Installation

  • from GitHub

    git clone https://github.com/codyverse/basex64.git
    cd basex64
    
  • via PIP

    pip install basex64
    

Usage

Options:

  -h, --help          Show this help message and exit.
  -i, --input         Path to the input file.
  -o, --output        Path to the output file.
      --inline        Inline data to encrypt/decrypt.
  -e, --encrypt       Encrypt the input file or data.
  -d, --decrypt       Decrypt the input file or data.
  -k, --key           Encryption/Decryption key.
  -l, --vector-length Length of the initialization vector (IV). Default: 16.
  -s, --vector-slice  Slice n symbols from the IV and prepend them to the ciphertext. Default: 0.
  -f, --force         Force rewrite of output file if it exists.
      --self-test     Self-test mode to verify encryption/decryption integrity with random data.

Examples

  • Encrypt the input.txt file and save the output as output.enc:

    python3 basex64.py -e -k your_secret_key -i input.txt -o output.enc
    
  • Decrypt the output.enc file and save the decrypted data to output.txt:

    python3 basex64.py -d -k your_secret_key -i output.enc -o output.txt
    
  • Encrypt inline data:

    python3 basex64.py -e -k your_secret_key --inline "Hello, World!"
    
  • Decrypt inline data:

    python3 basex64.py -d -k your_secret_key --inline "20c+U4QAm0AjyUhe3F374d794a95cdcfd8"
    
  • Perform self-testing (generating random data):

    python3 basex64.py --self-test 100
    

    This will run 100 iterations of random data encryption and decryption with random parameters to ensure the integrity of the cipher.

  • Encrypt inline data with the IV slicing using, for example, --vector-slice 8:

    python3 basex64.py -e -k your_secret_key --inline "Hello, World!" -s 8
    

    The encryption result will be 374d794a20c+U4QAm0AjyUhe3F95cdcfd8. In this case, 8 IV characters (374d794a) are added at the beginning, and the remainder (95cdcfd8) is left at the end of the data ciphertext (20c+U4QAm0AjyUhe3F). Obviously, if specify --vector-length 16 and --vector-slice 16, the entire IV (374d794a95cdcfd8) will be moved to the beginning of the ciphertext and the result will be 20c+U4QAm0AjyUhe3F374d794a95cdcfd8.

    This changes the structure of the ciphertext and adds an additional layer of security, since without knowing the encryption parameters, an attacker cannot directly recover the IV from the ciphertext. Important: To decrypt the ciphertext, you must specify the same --vector-slice value used during encryption.

Contributing

Feel free to contribute by submitting issues or pull requests!

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

basex64-0.0.1.250102.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

basex64-0.0.1.250102-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file basex64-0.0.1.250102.tar.gz.

File metadata

  • Download URL: basex64-0.0.1.250102.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for basex64-0.0.1.250102.tar.gz
Algorithm Hash digest
SHA256 04d0c13b0d4506a37a67e6ad20b2fa73ec4a6d50bd52f6d39783318262b813c6
MD5 915ece46c27c6805891232319b248082
BLAKE2b-256 6bb7cd307bd008a57e78ac874fb0b450cec4a7b68ffc0683669617d6e8bfcd42

See more details on using hashes here.

File details

Details for the file basex64-0.0.1.250102-py3-none-any.whl.

File metadata

File hashes

Hashes for basex64-0.0.1.250102-py3-none-any.whl
Algorithm Hash digest
SHA256 91e18f4d0a4e1bee7d90936ace24c0a4b4f1fffd57544961dbb14d1b1dae6d2e
MD5 66f9a5b6ac74d09f3adc0ff101e75109
BLAKE2b-256 36920c1870da3c3d43149d6911ca03c8d833c4b8cd54ba50630ad2aa40cafaec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page