Advanced Options
Learn about advanced options and features available in the Spro SDK.
The secure
method in the Spro SDK offers several advanced options to customize the masking process according to your specific requirements. These options allow you to fine-tune the masking behavior and achieve the desired level of data protection.
Mask Options
The secure method offers several customizable options to fit your requirements.
Parameters
-
prompt (str) (required)
- The text to be masked.
- Example: "My name is John Doe, and my email is john.doe@example.com"
-
mask_type (str) (optional)
- Specifies the type of masking to apply.
- Options:
- char: Masks with characters (e.g., *).
- label: Replaces entities with labels (e.g., [PERSON]).
- enhanced: Masks entities in markdown format (e.g., PERSON).
- Default: char
-
mask_char (str) (optional)
- The character used for masking.
- Default: *
- Example: Setting
mask_char
to # will replace text with ####.
-
entities (list) (optional)
- A list of specific entities to mask.
- Default: All Entities
- Example: ["PERSON", "EMAIL"] to mask only names and email addresses.
Example
from spro import Spro
# Initialize Spro
spro = Spro()
# Define the input
text = "My name is John Doe, and my email is john.doe@example.com."
# Apply masking with advanced options
result = spro.secure(
prompt=text,
mask_type="enhanced",
entities=["PERSON", "EMAIL"]
)
print(result["redacted_text"])
Output
{
"status": "success",
"redacted_text": "My name is **[PERSON]**, and my email is **[EMAIL]**",
"redacted_entities": [
{
"original": "John Doe",
"redacted": "**[PERSON]**",
"label": "PERSON",
"start": 11,
"end": 19
},
{
"original": "john.doe@example.com",
"redacted": "**[EMAIL]**",
"label": "EMAIL",
"start": 37,
"end": 57
}
],
"metadata": {
"mask_char": "*",
"mask_type": "enhanced",
"detected_entities": 2,
"redacted_entities": 2,
"confidence": 100.0,
"processing_time": 0.007374
},
"credits": {
"remaining_credits": 13.846095,
"redacted_cost": 5e-05
},
"request_id": "ec27d1df-4ced-4270-995c-0e69c3d2c032"
}
List of Entities Supported
Spro supports the following entities for masking:
Entity Name | Description | Example |
---|---|---|
API_KEY | Unique key used for API authentication | spro-1234567890abcdef |
Email addresses of individuals or organizations | john.doe@example.com | |
PHONE_NUMBER | Phone numbers in various formats | +1-234-567-8901 |
PERCENT | Percentage values | 50% |
PERSON | Names of individuals | John Doe |
IP_ADDRESS | Internet Protocol addresses | 192.168.1.1 |
LOCATION | Geographic locations (e.g., cities, countries) | New York, USA |
PAN_NUMBER | Permanent Account Numbers (used in India) | ABCDE1234F |
ORG | Organization names | Hrida AI |
CREDIT_CARD | Credit card numbers | 4111 1111 1111 1111 |
AADHAAR_NUMBER | Aadhaar numbers (Indian national ID) | 1234 5678 9101 |
URL | Web addresses | https://example.com |
UPI_ID | Unified Payments Interface ID (India) | john@upi |
USERNAME | Usernames for online accounts | john_doe123 |
PASSWORD | Password strings | P@ssw0rd! |
DATE_OF_BIRTH | Full dates of birth | 1990-01-01 |
DATE | General dates | 2024-12-09 |
LICENSE_PLATE | Vehicle license plate numbers | MH12 AB 1234 |
TIME | Time in various formats | 12:30 PM |
MAC_ADDRESS | Media Access Control (MAC) addresses | 00:1A:2B:3C:4D:5E |
GENDER | Gender identifiers | Male , Female |
SEXUALITY | Sexual orientation | Heterosexual , Bisexual |
BLOOD_GROUP | Blood types | O+ , AB- |
MONEY | Monetary values | $1000 , ₹7500 |
EVENT | Event names | Annual Tech Conference |
LANGUAGE | Languages spoken or written | English , Hindi |
PRODUCT | Product names | iPhone 15 |
AGE | Age values | 25 years |
MARITAL_STATUS | Marital status | Single , Married |
RELIGION | Religious affiliations | Christianity , Hinduism |
DOSAGE | Medical dosage details | 500mg twice daily |
MEDICAL_CONDITION | Medical conditions | Hypertension , Diabetes |
MEDICAL_PROCESS | Medical procedures | Surgery , Chemotherapy |
PASSPORT_NUMBER | Passport numbers | A1234567 |
DRIVER_LICENSE | Driver’s license numbers | DL-12345-2024 |
INJURY | Injury descriptions | Fractured arm |
SQL_QUERY | SQL statements | SELECT * FROM users |
NATIONALITY | Nationalities | Indian , American |
BANK_ACCOUNT_NUMBER | Bank account numbers | 123456789012 |
OCCUPATION | Occupations or job titles | Software Engineer |
HASH | Hash values | a1b2c3d4e5f6g7h8i9j0 |
OFFENSE_FILTER | Legal offenses | Theft , Fraud |
GST_NUMBER | Goods and Services Tax ID (India) | 22AAAAA0000A1Z5 |
CITATION | Legal or scholarly citations | Doe, J., 2024 |
COPYRIGHT | Copyright symbols | © 2024 Hrida AI |
TRADEMARK | Trademark names | ™ , ® |
CONTRACT | Contract-related phrases | Non-disclosure agreement |
POSTAL_CODE | Postal or ZIP codes | 10001 |
SSN_NUMBER | Social Security numbers (USA) | 123-45-6789 |
VOTER_ID | Voter identification numbers | AB1234567 |
SOCIAL_MEDIA_HANDLE | Social media usernames | @john_doe |
CVV_NUMBER | Credit card CVV codes | 123 |
GENDER_PRONOUN | Gender pronouns | He , She , They |
EMOJI | Emoji characters | 😊 , 🚀 |
IBAN_NUMBER | International Bank Account Numbers | GB33BUKB20201555555555 |
CRYPTO_ADDRESS | Cryptocurrency wallet addresses | 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa |
UUID | Universally Unique Identifiers | 123e4567-e89b-12d3-a456-426614174000 |
GEO_COORDINATES | Geographic latitude and longitude | 37.7749, -122.4194 |
With these advanced options, you can tailor the masking process to suit your specific use case and ensure that sensitive information is protected effectively.