Installation
Install the SDK using pip:Initialization
Basic Setup
With Custom Configuration
Context Manager (Recommended)
Use the context manager to ensure proper resource cleanup:Core Methods
Tokenize
Replace sensitive data with reversible tokens. Perfect for AI interactions where you need to restore original values later.text(str, required): The text to tokenizeconfig(dict, optional):entities(list[str]): List of entity types to detectscore_threshold(float): Minimum confidence score (0.0-1.0)
TokenizeResponse with:
text: Anonymized text with tokensmapping: Dictionary mapping tokens to original valuesdetected_entities: List of detected entities with detailsentities_count: Total number of entities found
Detokenize
Restore original values from tokens.text(str, required): Text containing tokensmapping(dict, required): Token-to-value mapping from tokenize response
DetokenizeResponse with:
text: Original text with tokens replacedreplacements_made: Number of token replacements
Mask
Partially hide sensitive data (e.g.,****-****-****-1234).
text(str, required): Text to maskmasking_char(str, optional): Character to use for masking (default:*)chars_to_show(int, optional): Number of characters to keep visible (default: 4)from_end(bool, optional): Show characters from end if True, start if False (default: True)
MaskResponse with:
text: Masked textdetected_entities: List of detected and masked entitiesentities_count: Number of entities masked
Redact
Permanently remove sensitive data.text(str, required): Text to redactentities(list[str], optional): Specific entity types to redactscore_threshold(float, optional): Minimum confidence score
RedactResponse with:
text: Redacted textdetected_entities: List of redacted entitiesentities_count: Number of entities redacted
Hash
Replace data with deterministic hashes. Useful for analytics and matching without exposing original values.text(str, required): Text to hashhash_type(str, optional): Hash algorithm -md5,sha1,sha224,sha256,sha384,sha512(default:sha256)hash_prefix(str, optional): Prefix for hash values (default:"")hash_length(int, optional): Length of hash to use (default: 16)
HashResponse with:
text: Text with hashed entitiesdetected_entities: List of hashed entitiesentities_count: Number of entities hashed
Synthesize
Replace real data with realistic fake data using Faker.text(str, required): Text to synthesizelanguage(str, optional): Language code for fake data generation -en,cs,de,fr,es,it,pl,sk(default:en)entities(list[str], optional): Specific entity types to synthesizescore_threshold(float, optional): Minimum confidence score
SynthesizeResponse with:
text: Text with synthesized datadetected_entities: List of replaced entitiesentities_count: Number of entities synthesized
Encrypt
Encrypt sensitive data using AES encryption (reversible with key).text(str, required): Text to encryptencryption_key(str, optional): Encryption key (min 16 characters). If not provided, uses tenant default.entities(list[str], optional): Specific entity types to encryptscore_threshold(float, optional): Minimum confidence score
EncryptResponse with:
text: Text with encrypted entitiesdetected_entities: List of encrypted entitiesentities_count: Number of entities encrypted
Async Support
The SDK fully supports asyncio for non-blocking operations:Supported Entity Types
The SDK automatically detects 50+ types of sensitive information:Personal Information
PERSON- Person namesEMAIL_ADDRESS- Email addressesPHONE_NUMBER- Phone numbersDATE_TIME- Dates and times
Financial Information
CREDIT_CARD- Credit card numbersIBAN_CODE- International Bank Account NumbersCRYPTO- Cryptocurrency addresses
Government IDs
US_SSN- US Social Security NumbersUS_DRIVER_LICENSE- US Driver LicensesUS_PASSPORT- US Passport NumbersNRP- National Registry Person (various countries)
Medical Information
MEDICAL_LICENSE- Medical license numbersUS_ITIN- Individual Taxpayer Identification Numbers
Technical Information
IP_ADDRESS- IP addresses (IPv4/IPv6)URL- URLs and domainsAPI_KEY- API keys and tokens
Location Information
LOCATION- Cities, addresses, and locationsADDRESS- Physical addresses
Error Handling
The SDK provides specific exception types for different error scenarios:AuthenticationError- Invalid or missing API keyAPIError- API validation or processing errors (includes status code)NetworkError- Connection issues, timeoutsException- Unexpected errors
Configuration Options
Entity Filtering
Filter which types of entities to detect:Confidence Threshold
Set minimum confidence score (0.0-1.0) for entity detection:Best Practices
1. Use Environment Variables for API Keys
2. Use Context Managers
3. Handle Errors Gracefully
4. Store Mappings Securely
When using tokenization, store the mapping securely for later detokenization:5. Use Async for High-Throughput Applications
Complete Example
Here’s a complete example integrating Blindfold with OpenAI:Need Help?
- GitHub Issues: Report bugs or request features
- Email Support: [email protected]
- Documentation: Check out the API Reference and Examples