{"id":23000,"library":"xxtea","title":"xxtea","description":"xxtea is a simple block cipher implementing the XXTEA encryption algorithm. Current version 4.0.0, requires Python >=3.9. Released under BSD license. Active development with periodic releases.","status":"active","version":"4.0.0","language":"python","source_language":"en","source_url":"https://github.com/ifduyue/xxtea","tags":["cryptography","xxtea","block-cipher","encryption"],"install":[{"cmd":"pip install xxtea","lang":"bash","label":"latest"}],"dependencies":[],"imports":[{"note":"The legacy API used different function names. Use the module-level functions.","wrong":"from xxtea import xxtea_encrypt","symbol":"encrypt","correct":"import xxtea; xxtea.encrypt(data, key, padding=True)"},{"note":"Direct import of decrypt works, but ensure you pass key as bytes, not string.","wrong":"from xxtea import decrypt","symbol":"decrypt","correct":"import xxtea; xxtea.decrypt(ciphertext, key, padding=True)"}],"quickstart":{"code":"import os\nimport xxtea\n\ndata = b'Hello, World!'\nkey = os.environ.get('XXTEA_KEY', 'secret').encode()\nencrypted = xxtea.encrypt(data, key)\nprint(encrypted.hex())\ndecrypted = xxtea.decrypt(encrypted, key)\nprint(decrypted)","lang":"python","description":"Encrypt and decrypt a bytes message using a key."},"warnings":[{"fix":"Use xxtea.encrypt_hex() if you need hex output, or call .hex() on the result.","message":"The encrypt() function returns bytes, not hex string as in some older versions or wrappers.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Always encode your key: b'key' or 'key'.encode()","message":"The key must be a bytes object; passing a string raises TypeError.","severity":"gotcha","affected_versions":"all"},{"fix":"Leave padding=True unless you have a specific reason.","message":"Padding is enabled by default. Disable with padding=False only if you manually handle block size alignment.","severity":"gotcha","affected_versions":">=1.2.0"},{"fix":"Upgrade to Python >=3.6, preferably >=3.9.","message":"Python 2.7, 3.4, 3.5 support dropped in v3.0.0.","severity":"deprecated","affected_versions":"<3.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Encode your key and data: key = b'secret', data = b'plaintext'","cause":"Key or data passed as string instead of bytes.","error":"TypeError: a bytes-like object is required, not 'str'"},{"fix":"Ensure the correct key is used and that ciphertext was not tampered with. Check encryption parameters (e.g., padding).","cause":"Decrypting with wrong key or corrupted ciphertext (padding validation fails).","error":"xxtea.error: Invalid padding"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}