Skip to main content

RC6Encryption logo

RC6Encryption

Description

This pure python package implements the RC6 encryption (ECB and CBC encryption mode).

All encryption and decryption mode are tested, i compare the result with https://www.lddgo.net/en/encrypt/rc6 API.

The ECB mode is not recommended, it's the basic encryption for block cipher, you should always use CBC encryption for data greater than 16 bytes.

Requirements

This package require:

  • python3
  • python3 Standard Library

Installation

Pip

python3 -m pip install RC6Encryption

Git

git clone "https://github.com/mauricelambert/RC6Encryption.git"
cd "RC6Encryption"
python3 -m pip install .

Wget

wget https://github.com/mauricelambert/RC6Encryption/archive/refs/heads/main.zip
unzip main.zip
cd RC6Encryption-main
python3 -m pip install .

cURL

curl -O https://github.com/mauricelambert/RC6Encryption/archive/refs/heads/main.zip
unzip main.zip
cd RC6Encryption-main
python3 -m pip install .

Usages

Recommended options

rc6 [key] -m CBC -6 -o [secrets.cipher] -i [secrets.file]            # encryption
rc6 [key] -m CBC -n base64 -i [secrets.cipher] -o [decipher.file] -d # decryption

Command line

Module

python3 -m RC6Encryption rc6key -s secrets

Python executable

python3 RC6Encryption.pyz rc6key -s secrets

Command

Basic
rc6 rc6key -s secrets                               # encrypt "secrets" with rc6key sha256 as key
Advanced
rc6 rc6key -r 12 -l 5 -w 32 -s secrets              # encrypt "secrets" with rc6key sha256 as key (rounds=12, wbit=32, lgw=5) in ECB mode
echo secrets| rc6 rc6key --no-sha256 -i             # encrypt "secrets\n" with key and PKCS 5/7 padding in ECB mode
rc6 rc6key -m CBC -I IVTEST -i secrets.txt          # encrypt secrets.txt file content with rc6key sha256 as key and CBC mode and IVTEST as IV
rc6 rc6key -o encrypt.rc6 -s secrets -m CBC         # encrypt "secrets" with rc6key sha256 as key, IVTEST as IV and redirect the output to the encrypt.rc6 file using CBC encryption mode and random IV
rc6 rc6key -i encrypt.rc6 -d -m CBC                 # decrypt encrypt.rc6 with rc6key sha256 as key using CBC encryption mode

## INPUT  ENCODING

rc6 rc6key -n base64 -s c2VjcmV0cw==                # encrypt "secrets" with rc6key sha256 as key ("c2VjcmV0cw==" = base64("secrets"))

## OUTPUT ENCODING

rc6 rc6key -s secrets -8                            # encrypt "secrets" with rc6key sha256 as key, base85-encoded output
rc6 rc6key -s secrets -6                            # encrypt "secrets" with rc6key sha256 as key, base64-encoded output
rc6 rc6key -s secrets -3                            # encrypt "secrets" with rc6key sha256 as key, base30-encoded output
rc6 rc6key -s secrets -1                            # encrypt "secrets" with rc6key sha256 as key, base16-encoded output
rc6 rc6key -s secrets -u                            # encrypt "secrets" with rc6key sha256 as key, uu-encoded output

Python script

RC6 encryption using CBC (recommended)

from RC6Encryption import RC6Encryption

rc6 = RC6Encryption(b'abcdefghijklm')
iv, encrypt = rc6.data_encryption_CBC(b'abcdefghijklmnopabcdefghijklmnopabcdefghijklm')             # Random IV
plaintext = rc6.data_decryption_CBC(encrypt, iv)

iv, encrypt = rc6.data_encryption_CBC(b'abcdefghijklmnopabcdefghijklmnopabcdefghijklm', b'IVTEST')  # Generate your IV, be careful, an IV with size less than 16 bytes is not recommended
plaintext = rc6.data_decryption_CBC(encrypt, iv)

RC6 encryption using ECB (not recommended)

from RC6Encryption import RC6Encryption

rc6 = RC6Encryption(b'abcdefghijklm')
encrypt = rc6.data_encryption_ECB(b'abcdefghijklmnopabcdefghijklmnopabcdefghijklm')
plaintext = rc6.data_decryption_ECB(encrypt)

Low level API

from RC6Encryption import RC6Encryption
from hashlib import sha256

rc6 = RC6Encryption(sha256(b'abcdefghijklmnop').digest())
cipher = rc6.blocks_to_data(rc6.encrypt(b'abcdefghijklmnop'))
decipher = rc6.blocks_to_data(rc6.decrypt(cipher))

Links

Help

usage: RC6Encryption.py [-h] [--mode {CBC,ECB}] [--decryption] (--input-file [INPUT_FILE] | --input-string INPUT_STRING) [--output-file OUTPUT_FILE]
                        [--base85 | --base64 | --base32 | --base16 | --output-encoding {base32,base16,base64,base85}]
                        [--input-encoding {base32,base16,base64,base85}] [--rounds ROUNDS] [--w-bit W_BIT] [--iv IV] [--lgw LGW] [--sha256 | --no-sha256]
                        key

This script performs RC6 encryption.

positional arguments:
  key                   Encryption key.

options:
  -h, --help            show this help message and exit
  --mode {CBC,ECB}, -m {CBC,ECB}
                        Ecryption mode, for CBC encryption IV is write on the first 16 bytes of the encrypted data.
  --decryption, -d      Data decryption.
  --input-file [INPUT_FILE], --i-file [INPUT_FILE], -i [INPUT_FILE]
                        The file to be encrypted.
  --input-string INPUT_STRING, --string INPUT_STRING, -s INPUT_STRING
                        The string to be encrypted.
  --output-file OUTPUT_FILE, --o-file OUTPUT_FILE, -o OUTPUT_FILE
                        The output file.
  --base85, --85, -8    Base85 encoding as output format
  --base64, --64, -6    Base64 encoding as output format
  --base32, --32, -3    Base32 encoding as output format
  --base16, --16, -1    Base16 encoding as output format
  --output-encoding {base32,base16,base64,base85}, --o-encoding {base32,base16,base64,base85}, -e {base32,base16,base64,base85}
                        Output encoding.
  --input-encoding {base32,base16,base64,base85}, --i-encoding {base32,base16,base64,base85}, -n {base32,base16,base64,base85}
                        Input encoding.
  --rounds ROUNDS, -r ROUNDS
                        RC6 rounds
  --w-bit W_BIT, -b W_BIT
                        RC6 w-bit
  --iv IV, -I IV        IV for CBC mode only, for decryption if IV is not set the 16 first bytes are used instead.
  --lgw LGW, -l LGW     RC6 lgw
  --sha256, --no-sha256
                        Use the sha256 hash of the key as the key.

Licence

Licensed under the GPL, version 3.

Metadata

Release files for RC6Encryption 1.0.1

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

Source distribution (sdist)

Source distribution for RC6Encryption 1.0.1
File Size Uploaded
rc6encryption-1.0.1.tar.gz 24.4 kB Details

Release files / rc6encryption-1.0.1.tar.gz

Download URL rc6encryption-1.0.1.tar.gz
Size 24.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f81ac5bc4d0351f86e1e841b9bf1ec26843691d06810681e6192a557c70826e4
BLAKE2b-256 checksum
How to use checksums
08f34a560d64b8de7eaac9c42454d9cd290450c81e745f6c816d535832756cb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.8

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

1.0.0

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

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