Skip to main content

Simple, reusable and optimized XOR ciphers in Python.

Project description

xor-cipher

License Version Downloads

Documentation Check Test Coverage

Simple, reusable and optimized XOR ciphers in Python.

xor-cipher is a fast implementation of the XOR cipher written using Cython. Our tests show that it can be 1000x faster than pure Python implementations. It has been optimized to breeze through datasets of any size.

Installing

Python 3.8 or above is required.

pip

Installing the library with pip is quite simple:

$ pip install xor-cipher

Alternatively, the library can be installed from source:

$ git clone https://github.com/xor-cipher/xor-cipher.git
$ cd xor-cipher
$ python -m pip install .

poetry

You can add xor-cipher as a dependency with the following command:

$ poetry add xor-cipher

Or by directly specifying it in the configuration like so:

[tool.poetry.dependencies]
xor-cipher = "^4.0.0"

Alternatively, you can add it directly from the source:

[tool.poetry.dependencies.xor-cipher]
git = "https://github.com/xor-cipher/xor-cipher.git"

Examples

Simple Cipher

Use the xor function to perform the simple XOR cipher:

>>> from xor_cipher import xor
>>> xor(b"Hello, world!", 0x42)
b"\n'..-nb5-0.&c"

Cyclic Cipher

Use the cyclic_xor function to perform the cyclic XOR variation:

>>> from xor_cipher import cyclic_xor
>>> cyclic_xor(b"Hello, world!", b"BLOB")
b"\n)#.-`o5->#&c"

In-Place Cipher

There are functions to perform the XOR cipher in-place, on bytearray instances:

>>> from xor_cipher import xor_in_place
>>> data = bytearray(b"Hello, world!")
>>> xor_in_place(data, 0x42)
>>> data
bytearray(b"\n'..-nb5-0.&c")

Documentation

You can find the documentation here.

Support

If you need support with the library, you can send an email.

Changelog

You can find the changelog here.

Security Policy

You can find the Security Policy of xor-cipher here.

Contributing

If you are interested in contributing to xor-cipher, make sure to take a look at the Contributing Guide, as well as the Code of Conduct.

License

xor-cipher is licensed under the MIT License terms. See License 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

xor_cipher-4.0.0.tar.gz (6.2 kB view hashes)

Uploaded Source

Built Distributions

xor_cipher-4.0.0-cp312-cp312-win_amd64.whl (25.9 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

xor_cipher-4.0.0-cp312-cp312-manylinux_2_35_x86_64.whl (136.3 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.35+ x86-64

xor_cipher-4.0.0-cp312-cp312-macosx_12_0_x86_64.whl (45.1 kB view hashes)

Uploaded CPython 3.12 macOS 12.0+ x86-64

xor_cipher-4.0.0-cp311-cp311-win_amd64.whl (25.8 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

xor_cipher-4.0.0-cp311-cp311-manylinux_2_35_x86_64.whl (127.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.35+ x86-64

xor_cipher-4.0.0-cp311-cp311-macosx_12_0_x86_64.whl (44.5 kB view hashes)

Uploaded CPython 3.11 macOS 12.0+ x86-64

xor_cipher-4.0.0-cp310-cp310-win_amd64.whl (25.8 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

xor_cipher-4.0.0-cp310-cp310-manylinux_2_35_x86_64.whl (112.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.35+ x86-64

xor_cipher-4.0.0-cp310-cp310-macosx_12_0_x86_64.whl (25.5 kB view hashes)

Uploaded CPython 3.10 macOS 12.0+ x86-64

xor_cipher-4.0.0-cp39-cp39-win_amd64.whl (25.8 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

xor_cipher-4.0.0-cp39-cp39-manylinux_2_35_x86_64.whl (112.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.35+ x86-64

xor_cipher-4.0.0-cp39-cp39-macosx_12_0_x86_64.whl (25.4 kB view hashes)

Uploaded CPython 3.9 macOS 12.0+ x86-64

xor_cipher-4.0.0-cp38-cp38-win_amd64.whl (25.8 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

xor_cipher-4.0.0-cp38-cp38-manylinux_2_35_x86_64.whl (112.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.35+ x86-64

xor_cipher-4.0.0-cp38-cp38-macosx_12_0_x86_64.whl (25.4 kB view hashes)

Uploaded CPython 3.8 macOS 12.0+ x86-64

Supported by

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