Skip to content

Commit abbd5fd

Browse files
author
Kevin P. Dyer
committed
Add cleaner PyPI-specific README
- Create README_PYPI.md with focused content for package users - Remove installation, testing, benchmarks, project structure sections - Keep quick start, API reference, spec, and security info - Update .gitignore for build artifacts - Bump to 1.0.1
1 parent 7242cb6 commit abbd5fd

4 files changed

Lines changed: 111 additions & 4 deletions

File tree

.gitignore

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
1-
*.pyc
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# Distribution / packaging
7+
build/
8+
dist/
9+
*.egg-info/
10+
*.egg
11+
12+
# Virtual environments
13+
venv/
14+
.venv/
15+
env/
16+
17+
# IDE
18+
.idea/
19+
.vscode/
20+
*.swp
21+
*.swo
22+
23+
# Testing
24+
.pytest_cache/
25+
.coverage
26+
htmlcov/
27+
.tox/
28+
29+
# mypy
30+
.mypy_cache/

README_PYPI.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# libffx - Format Preserving Encryption
2+
3+
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5+
6+
A Python implementation of the FFX Mode of Operation for Format-Preserving Encryption (FPE).
7+
8+
Format-preserving encryption encrypts data while preserving its format. For example, a 16-digit credit card number encrypts to another 16-digit number, and a 9-digit SSN encrypts to another 9-digit number.
9+
10+
## Quick Start
11+
12+
```python
13+
import ffx
14+
15+
# 128-bit key (as hex)
16+
key = ffx.FFXInteger('2b7e151628aed2a6abf7158809cf4f3c', radix=16, blocksize=32)
17+
18+
# Create encrypter for decimal digits
19+
ffx_obj = ffx.new(key.to_bytes(16), radix=10)
20+
21+
# Encrypt a credit card number
22+
cc_number = ffx.FFXInteger('4111111111111111', radix=10, blocksize=16)
23+
tweak = ffx.FFXInteger('0000000000', radix=10, blocksize=10)
24+
25+
encrypted = ffx_obj.encrypt(tweak, cc_number)
26+
decrypted = ffx_obj.decrypt(tweak, encrypted)
27+
28+
print(f"Original: {cc_number}") # 4111111111111111
29+
print(f"Encrypted: {encrypted}") # 3847592710482695
30+
print(f"Decrypted: {decrypted}") # 4111111111111111
31+
```
32+
33+
## API Reference
34+
35+
### `ffx.new(key, radix)`
36+
37+
Create a new FFX encrypter.
38+
39+
- `key`: 16-byte AES-128 key
40+
- `radix`: Base for message alphabet (2-36)
41+
42+
### `FFXInteger(value, radix=2, blocksize=None)`
43+
44+
Represent a value in a specific radix.
45+
46+
- `value`: Integer, string representation, or another FFXInteger
47+
- `radix`: Base (2-36)
48+
- `blocksize`: Minimum output length (zero-padded)
49+
50+
### `FFXEncrypter.encrypt(tweak, plaintext)` / `.decrypt(tweak, ciphertext)`
51+
52+
Encrypt/decrypt with an optional tweak (public associated data).
53+
54+
## Specification
55+
56+
This implementation follows the [NIST FFX-A2 specification](http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/ffx/ffx-spec2.pdf):
57+
58+
- **Cipher**: AES-128
59+
- **Mode**: Maximally-balanced Feistel network
60+
- **Rounds**: 10 (constant)
61+
- **Radix**: 2–36 (binary through alphanumeric)
62+
63+
## Security Considerations
64+
65+
- FFX is designed for format-preserving encryption of small domains
66+
- Security depends on domain size; very small domains may be vulnerable to brute force
67+
- Always use cryptographically random keys
68+
- Tweaks should be unique per encryption when possible
69+
70+
## Links
71+
72+
- [GitHub Repository](https://github.com/kpdyer/libffx)
73+
- [Issue Tracker](https://github.com/kpdyer/libffx/issues)
74+
- [NIST FFX Specification](http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/ffx/ffx-spec2.pdf)
75+
76+
## License
77+
78+
MIT License

ffx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
'bytes_to_long',
4545
]
4646

47-
__version__ = '1.0.0'
47+
__version__ = '1.0.1'
4848

4949

5050
def new(key: bytes, radix: int) -> FFXEncrypter:

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "libffx"
7-
version = "1.0.0"
7+
version = "1.0.1"
88
description = "FFX - Format Preserving Encryption (NIST FFX-A2 mode of operation)"
9-
readme = "README.md"
9+
readme = "README_PYPI.md"
1010
license = {text = "MIT"}
1111
authors = [
1212
{name = "Kevin P. Dyer", email = "kpdyer@gmail.com"}

0 commit comments

Comments
 (0)