Skip to main content

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.

Metadata

Release files for basex64 0.0.1.250102

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for basex64 0.0.1.250102
File Size Uploaded
basex64-0.0.1.250102.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for basex64 0.0.1.250102
File Interpreter ABI Platform
basex64-0.0.1.250102-py3-none-any.whl Python 3 none any Details

Total release size: 16.1 kB

Release files / basex64-0.0.1.250102.tar.gz

Download URL basex64-0.0.1.250102.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
04d0c13b0d4506a37a67e6ad20b2fa73ec4a6d50bd52f6d39783318262b813c6
BLAKE2b-256 checksum
How to use checksums
6bb7cd307bd008a57e78ac874fb0b450cec4a7b68ffc0683669617d6e8bfcd42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Release files / basex64-0.0.1.250102-py3-none-any.whl

Download URL basex64-0.0.1.250102-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
91e18f4d0a4e1bee7d90936ace24c0a4b4f1fffd57544961dbb14d1b1dae6d2e
BLAKE2b-256 checksum
How to use checksums
36920c1870da3c3d43149d6911ca03c8d833c4b8cd54ba50630ad2aa40cafaec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Release history Release notifications | RSS feed

This release

0.0.1.250102 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page