API reference

arc4 module

ARCFOUR (RC4) implementation in Python/C API.

class arc4.ARC4

A class represents a session of RC4 stream cipher.

__init__(key: bytes)

key : bytes
A key to encrypt or decrypt.
ValueError
When the key length is zero.

You have to initialize an instance in the beginning of each operations.

decrypt(data: bytes) → bytes

Decrypt cipher with a given key.

data : bytes
Encrypted data.
bytes
Decrypted data.

This method is defined for readability although it is identical to encrypt().

>>> arc4 = ARC4(b'spam')
>>> arc4.decrypt(b'\xda/S')
b'ham'
encrypt(data: bytes) → bytes

Encrypt cipher with a given key.

data : bytes
Decrypted data.
bytes
Encrypted data.

This method is defined for readability although it is identical to decrypt().

>>> arc4 = ARC4(b'spam')
>>> arc4.encrypt(b'ham')
b'\xda/S'