identity-fingerprint
Deterministic Customer Identity (CID) generation for Customer 360 and Master Data Management (MDM) use cases.
Multiple source systems rarely store customer data the same way: casing,
whitespace, phone formatting and null tokens all differ. identity-fingerprint
standardises the inputs, then produces a stable SHA-256 fingerprint so the same
real-world customer resolves to the same CID everywhere.
Features
- Deterministic SHA-256 CID from first name + last name + phone + email
- Automatic input standardisation (trim, lowercase, null handling, phone normalisation)
- Phone validation (last 10 digits, leading digit must be 6-9)
- Simple public API: a single
generate_cid(...)call - Type hints, docstrings, logging, custom exceptions
- Optional pandas integration for bulk DataFrame processing
- Zero required runtime dependencies
Installation
pip install identity-fingerprint
With optional pandas support:
pip install "identity-fingerprint[pandas]"
From source (editable, with dev tools):
pip install -e ".[dev]"
Requires Python 3.9+.
Quick start
from identity_fingerprint import generate_cid
cid = generate_cid(
first_name="John",
last_name="Smith",
email="john@gmail.com",
phone="9876543210",
)
print(cid) # 64-character SHA-256 hex digest
Differently formatted records for the same customer produce the same CID:
a = generate_cid("John", "Smith", "john@gmail.com", "9876543210")
b = generate_cid(" john ", " SMITH ", "JOHN@GMAIL.COM", "+91-9876543210")
assert a == b
Public API
generate_cid(
first_name: str,
last_name: str,
email: str = "",
phone: str = "",
) -> str
Also exported: clean_name, clean_email, clean_phone, sha256_hash,
and the exceptions IdentityFingerprintError, ValidationError,
InvalidPhoneNumberError.
Cleaning / matching rules
| Field | Rules |
|---|---|
| Name | trim whitespace, lowercase |
trim, lowercase, map null / none / nan → "" |
|
| Phone | strip spaces/dots/dashes/+, digits only, keep last 10, reject if not 10 digits or if leading digit is 0-5 |
The canonical identity string is concatenated as:
cleaned_first_name + cleaned_last_name + cleaned_phone + cleaned_email
then hashed with SHA-256.
Error handling
from identity_fingerprint import generate_cid
from identity_fingerprint.exceptions import InvalidPhoneNumberError, ValidationError
try:
generate_cid("John", "Smith", phone="12345") # too few digits
except InvalidPhoneNumberError as exc:
print("bad phone:", exc)
try:
generate_cid("", "", email="x@y.com") # no name
except ValidationError as exc:
print("validation:", exc)
Enable logging to see cleaning / hashing activity:
import logging
logging.basicConfig(level=logging.DEBUG)
Pandas integration
import pandas as pd
from identity_fingerprint import generate_cid
df = pd.DataFrame({
"first_name": ["John", "Jane"],
"last_name": ["Smith", "Doe"],
"email": ["john@gmail.com", "jane@doe.com"],
"phone": ["+91-9876543210", "9123456780"],
})
# Direct apply
df["CID"] = df.apply(
lambda r: generate_cid(r["first_name"], r["last_name"], r["email"], r["phone"]),
axis=1,
)
# Or use the helper (install the [pandas] extra)
from identity_fingerprint.pandas_integration import add_cid_column
df = add_cid_column(df, errors="coerce") # bad rows -> None instead of raising
Building the package
pip install build
python -m build
This produces dist/identity_fingerprint-<version>-py3-none-any.whl and a
source tarball. Validate metadata before publishing:
pip install twine
twine check dist/*
Publishing
Public PyPI
Manual (token-based):
python -m build
twine upload dist/*
# username: __token__ password: <your PyPI API token>
Recommended: Trusted Publishing (OIDC) via GitHub Actions — see
.github/workflows/release.yml. No tokens stored; configure a publisher at
https://pypi.org/manage/account/publishing/. Test first against TestPyPI:
twine upload --repository testpypi dist/*
AWS CodeArtifact
aws codeartifact login \
--tool twine \
--domain my-domain \
--domain-owner 111122223333 \
--repository my-repo
python -m build
twine upload --repository codeartifact dist/*
Install from CodeArtifact:
aws codeartifact login --tool pip --domain my-domain \
--domain-owner 111122223333 --repository my-repo
pip install identity-fingerprint
Azure Artifacts
Create ~/.pypirc (or use az artifacts + a PAT):
[distutils]
index-servers = azure
[azure]
repository = https://pkgs.dev.azure.com/<org>/<project>/_packaging/<feed>/pypi/upload/
username = <org>
password = <personal-access-token>
pip install twine keyring artifacts-keyring
python -m build
twine upload --repository azure dist/*
Install:
pip install identity-fingerprint \
--index-url https://pkgs.dev.azure.com/<org>/<project>/_packaging/<feed>/pypi/simple/
Versioning strategy
This project follows Semantic Versioning MAJOR.MINOR.PATCH:
- MAJOR — incompatible API changes, or any change to cleaning rules / concatenation order that alters produced CIDs (CID stability is part of the public contract).
- MINOR — backward-compatible functionality (new helpers, new optional args).
- PATCH — backward-compatible bug fixes and docs.
The version is defined in two places kept in sync: pyproject.toml and
__version__ in src/identity_fingerprint/__init__.py.
Automated release flow
- Bump the version in
pyproject.tomland__init__.py. - Commit and tag:
git tag v0.1.0 && git push --tags. - The
release.ymlworkflow builds the sdist + wheel and publishes to PyPI via OIDC trusted publishing on the tag push (or on a published GitHub Release). - CI (
ci.yml) runs lint, type-check and tests across Python 3.9-3.12 on every push and PR tomain.
Development
pip install -e ".[dev]"
pytest --cov=identity_fingerprint
ruff check .
mypy
License
MIT — see LICENSE.
Metadata
Release files for identity-fingerprint 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| identity_fingerprint-0.1.0.tar.gz | 14.7 kB | Without provenance | Details for identity_fingerprint-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| identity_fingerprint-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for identity_fingerprint-0.1.0-py3-none-any.whl |
Total release size: 26.9 kB
Release files / identity_fingerprint-0.1.0.tar.gz
| Download URL | identity_fingerprint-0.1.0.tar.gz |
|---|---|
| Size | 14.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e0b15efe3bf77d3b9582823746248daac0bce914bf86d18855a0f9227e371ba
|
|
BLAKE2b-256 checksum How to use checksums |
de6d5f29a112291af6a51f60b69f263e03be679daf8ea38eb574fcea51d22a89
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.1
|
Release files / identity_fingerprint-0.1.0-py3-none-any.whl
| Download URL | identity_fingerprint-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c7ecff64220a133cc22a142211078d687ed7ea7fc9450625a894131596241422
|
|
BLAKE2b-256 checksum How to use checksums |
030b25f1aa841c6bbc46548ad4c9dd9c75933c5798c312ad2e518fb19e023774
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.1
|
Security for identity-fingerprint 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.