xxtea
xxtea is a simple block cipher
What it is and what it does
xxtea is a compiled Python extension wrapping the XXTEA symmetric block cipher algorithm. It takes a 128-bit (16-byte) key and encrypts or decrypts data in 32-bit word blocks. The package handles byte-to-word conversions automatically and applies a non-standard 4-byte block PKCS#7 padding by default to ensure input data meets XXTEA's requirement of at least 2 words (8 bytes) and a multiple of 4 bytes. This means you can encrypt arbitrary binary data of any length without manual padding.
The module exports four module-level functions—encrypt(), decrypt(), encrypt_hex(), and decrypt_hex()—plus an XXTEA class for creating reusable cipher objects that store the key, padding mode, and round count. Rounds default to 6 + 52/n (where n is the number of 32-bit words), but can be overridden. The non-standard padding scheme makes output incompatible with other XXTEA implementations; use padding=False for raw XXTEA if interoperability is required, though this imposes strict data-length constraints.
Use it for:
- Encrypt sensitive binary data (credentials, tokens, session data) in Python applications where XXTEA compatibility is needed.
- Implement legacy system integration where XXTEA is the mandated cipher for cross-platform communication.
- Encrypt arbitrary-length byte strings without manual padding logic by relying on the built-in PKCS#7 scheme.
- Create reusable cipher objects for batch encryption/decryption of multiple messages with the same key and settings.
- Hex-encode encrypted output for storage or transmission in text-based formats (databases, logs, APIs).
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
xxtea is a Python extension that implements the XXTEA block cipher algorithm, providing functions to encrypt and decrypt data with a 128-bit key using a non-standard 4-byte PKCS#7 padding scheme.
Yes, if you need XXTEA specifically for legacy compatibility or cross-platform communication. The package is actively maintained, has no known vulnerabilities, supports modern Python versions (3.9–3.15), and offers prebuilt wheels for easy installation. However, be aware that its non-standard padding makes output incompatible with other XXTEA libraries; use only if interoperability with this specific implementation is required. For new projects, consider modern alternatives like cryptography or nacl.
Install
xxtea on PyPI
pip
pip install xxteauv
uv add xxteapoetry
poetry add xxteaInstalling xxtea
Before you install
Medium install friction due to compiled C extension wheels; however, prebuilt wheels are available for Python 3.9–3.15 across major platforms (Linux, macOS, Windows) and architectures, reducing build barriers. Active maintenance with recent release.
License in practice
BSD-2-Clause is permissive; you may use, modify, and distribute this package freely in proprietary or open-source projects with minimal restrictions, provided you retain the license notice.
Quickstart
import os
import xxtea
key = os.urandom(16) # 16-byte key required
data = b"xxtea is good"
enc = xxtea.encrypt(data, key)
dec = xxtea.decrypt(enc, key)
assert data == dec
# Or use the XXTEA type for reusable cipher
cipher = xxtea.XXTEA(key)
enc2 = cipher.encrypt(data)
dec2 = cipher.decrypt(enc2)
Key must be exactly 16 bytes; data length must be a multiple of 4 bytes and at least 8 bytes when padding=False is used.
Verify before relying
- Compatibility with other XXTEA implementations outside this library (non-standard padding may limit interoperability).
- Performance characteristics compared to other Python encryption libraries for typical use cases.
- Whether the free-threading support (Python 3.13+) has been tested in production multi-threaded scenarios.
Package facts
| License | BSD-2-Clause (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 0 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 275,811/month — #8,171 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: xxtea-5.3.3-cp310-cp310-macosx_10_9_x86_64.whl; xxtea-5.3.3-cp310-cp310-macosx_11_0_arm64.whl; xxtea-5.3.3-cp310-cp310-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl; xxtea-5.3.3-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; xxtea-5.3.3-cp310-cp310-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl; xxtea-5.3.3-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl; xxtea-5.3.3-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl; xxtea-5.3.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; xxtea-5.3.3-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl; xxtea-5.3.3-cp310-cp310-musllinux_1_2_aarch64.whl; xxtea-5.3.3-cp310-cp310-musllinux_1_2_armv7l.whl; xxtea-5.3.3-cp310-cp310-musllinux_1_2_i686.whl; xxtea-5.3.3-cp310-cp310-musllinux_1_2_ppc64le.whl; xxtea-5.3.3-cp310-cp310-musllinux_1_2_riscv64.whl; xxtea-5.3.3-cp310-cp310-musllinux_1_2_s390x.whl; xxtea-5.3.3-cp310-cp310-musllinux_1_2_x86_64.whl; xxtea-5.3.3-cp310-cp310-win32.whl; xxtea-5.3.3-cp310-cp310-win_amd64.whl; xxtea-5.3.3-cp310-cp310-win_arm64.whl; xxtea-5.3.3-cp311-cp311-macosx_10_9_x86_64.whl
Keywords: xxtea
Tags
More Cryptography packages
Certifi provides Mozilla's curated collection…
copyleft · top 100 on PyPI
cryptographycryptography provides cryptographic recipes and…
permissive · top 100 on PyPI
rsaPure-Python RSA encryption, decryption,…
permissive · top 1,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
azure-identityProvides Microsoft Entra ID token-based…
unclear · top 1,000 on PyPI
PyNaClPyNaCl provides Python bindings to libsodium…
permissive · top 1,000 on PyPI
twofishProvides Python bindings to the Twofish block…
permissive · top 15,000 on PyPI
aes-pkcs5Provides AES encryption and decryption with…
permissive · top 15,000 on PyPI
pyDesPure Python implementation of DES and Triple…
permissive · top 15,000 on PyPI
pyaesPure-Python implementation of AES encryption…
permissive · top 5,000 on PyPI
aws-encryption-sdkEncrypts and decrypts data using AWS KMS keys…
permissive · top 5,000 on PyPI
kasa-cryptProvides fast encryption and decryption…
permissive · top 15,000 on PyPI
http-eceImplements encrypted content encoding for HTTP…
permissive · top 5,000 on PyPI
pyhpkePyHPKE implements HPKE (Hybrid Public Key…
permissive · top 15,000 on PyPI
unpaddedbase64Encodes and decodes Base64 data without RFC…
permissive · top 5,000 on PyPI
eciespyEncrypts and decrypts data using Elliptic Curve…
permissive · top 15,000 on PyPI