{"id":21749,"library":"pyffx","title":"pyffx","description":"Pure Python implementation of Format Preserving Encryption (FPE) using the FF1 algorithm from NIST SP 800-38G. Supports integer and string alphabets. Current version 0.3.0, no recent releases.","status":"maintenance","version":"0.3.0","language":"python","source_language":"en","source_url":"https://github.com/emulbreh/pyffx","tags":["format-preserving encryption","FPE","FF1","cryptography"],"install":[{"cmd":"pip install pyffx","lang":"bash","label":"Latest stable"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"Integer","correct":"from pyffx import Integer"},{"note":"","wrong":"","symbol":"String","correct":"from pyffx import String"}],"quickstart":{"code":"from pyffx import Integer, String\n\n# Key must be 16, 24, or 32 bytes\nkey = b'mysecretkey12345'  # 16 bytes\n\n# Encrypt an integer up to 10^6-1\nfpe_int = Integer(key, radix=10, length=6)\nplaintext_int = 123456\nciphertext_int = fpe_int.encrypt(plaintext_int)\nprint(f'{plaintext_int} -> {ciphertext_int}')\ndecrypted_int = fpe_int.decrypt(ciphertext_int)\nprint(f'{ciphertext_int} -> {decrypted_int}')\n\n# Encrypt a string with custom alphabet\nfpe_str = String(key, alphabet='abcdefghijklmnopqrstuvwxyz', length=10)\nplaintext_str = 'helloworld'\nciphertext_str = fpe_str.encrypt(plaintext_str)\nprint(f'{plaintext_str} -> {ciphertext_str}')\ndecrypted_str = fpe_str.decrypt(ciphertext_str)\nprint(f'{ciphertext_str} -> {decrypted_str}')","lang":"python","description":"Basic usage of Integer and String FPE"},"warnings":[{"fix":"Ensure key is bytes and length is 16, 24, or 32.","message":"Key must be exactly 16, 24, or 32 bytes (AES key length). If your key is a string, encode to bytes first.","severity":"gotcha","affected_versions":"all"},{"fix":"Cast to int: fpe_int.encrypt(int('123456'))","message":"Integer encrypt/decrypt expect a plain integer, not a string. Passing a string will raise TypeError.","severity":"gotcha","affected_versions":"all"},{"fix":"Use alphabet with unique characters, e.g., '0123456789'.","message":"String alphabet must contain only unique characters. Duplicates cause incorrect encryption.","severity":"gotcha","affected_versions":"all"},{"fix":"Consider using alternatives like 'pycryptodome' or 'mbi-omapi' for FPE.","message":"Library is unmaintained since 2014. No active development; may not be suitable for production without review.","severity":"deprecated","affected_versions":"0.3.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"pip install pyffx","cause":"Library not installed or installed in wrong environment.","error":"ModuleNotFoundError: No module named 'pyffx'"},{"fix":"Generate a key of exactly 16, 24, or 32 bytes: key = b'0123456789abcdef'","cause":"Key length incorrect.","error":"ValueError: The key must be either 16, 24, or 32 bytes"},{"fix":"Ensure alphabet length is >= the length parameter. For Integer, radix is fixed.","cause":"Alphabet length mismatch when using custom length.","error":"ValueError: alphabet must contain exactly 'length' characters"},{"fix":"Pass an integer: fpe_int.encrypt(12345)","cause":"Passed a list instead of integer to Integer.encrypt.","error":"TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}