arc4

Test Test Coverage Maintainability Documentation Status

A small and insanely fast ARCFOUR (RC4) cipher implementation of Python.

  • Strongly focused on performance; entire source code is written in C.
  • Thread-safety; you can improve further performance with multi-threading.
  • Easily installable; single file with no dependency, pre-built wheels provided.

Benchmark

Below is benchmark metrics against 3 major RC4 implementations.

Benchmark

The whole benchmark code is in ./benchmark.py.

Note

arc4 supports multi-threading but it is too fast to ignore the overhead of context-switching, in most cases.

Install

Install from PyPI

pip install arc4

Or clone the repo and do install

git clone https://github.com/manicmaniac/arc4.git
cd arc4
python setup.py install

Usage

>>> from arc4 import ARC4
>>> arc4 = ARC4(b'key')
>>> cipher = arc4.encrypt(b'some plain text to encrypt')

Because RC4 is a stream cipher, you must initialize RC4 object in the beginning of each operations.

>>> arc4 = ARC4(b'key')
>>> arc4.decrypt(cipher)
b'some plain text to encrypt'

Documents

Here is the API reference.

https://arc4.readthedocs.io/en/latest/

Testing

python -m unittest discover

License

This software is under the MIT License.