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

  1. prompt (str) (required)

  2. 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
  3. mask_char (str) (optional)

    • The character used for masking.
    • Default: *
    • Example: Setting mask_char to # will replace text with ####.
  4. 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 NameDescriptionExample
API_KEYUnique key used for API authenticationspro-1234567890abcdef
EMAILEmail addresses of individuals or organizationsjohn.doe@example.com
PHONE_NUMBERPhone numbers in various formats+1-234-567-8901
PERCENTPercentage values50%
PERSONNames of individualsJohn Doe
IP_ADDRESSInternet Protocol addresses192.168.1.1
LOCATIONGeographic locations (e.g., cities, countries)New York, USA
PAN_NUMBERPermanent Account Numbers (used in India)ABCDE1234F
ORGOrganization namesHrida AI
CREDIT_CARDCredit card numbers4111 1111 1111 1111
AADHAAR_NUMBERAadhaar numbers (Indian national ID)1234 5678 9101
URLWeb addresseshttps://example.com
UPI_IDUnified Payments Interface ID (India)john@upi
USERNAMEUsernames for online accountsjohn_doe123
PASSWORDPassword stringsP@ssw0rd!
DATE_OF_BIRTHFull dates of birth1990-01-01
DATEGeneral dates2024-12-09
LICENSE_PLATEVehicle license plate numbersMH12 AB 1234
TIMETime in various formats12:30 PM
MAC_ADDRESSMedia Access Control (MAC) addresses00:1A:2B:3C:4D:5E
GENDERGender identifiersMale, Female
SEXUALITYSexual orientationHeterosexual, Bisexual
BLOOD_GROUPBlood typesO+, AB-
MONEYMonetary values$1000, ₹7500
EVENTEvent namesAnnual Tech Conference
LANGUAGELanguages spoken or writtenEnglish, Hindi
PRODUCTProduct namesiPhone 15
AGEAge values25 years
MARITAL_STATUSMarital statusSingle, Married
RELIGIONReligious affiliationsChristianity, Hinduism
DOSAGEMedical dosage details500mg twice daily
MEDICAL_CONDITIONMedical conditionsHypertension, Diabetes
MEDICAL_PROCESSMedical proceduresSurgery, Chemotherapy
PASSPORT_NUMBERPassport numbersA1234567
DRIVER_LICENSEDriver’s license numbersDL-12345-2024
INJURYInjury descriptionsFractured arm
SQL_QUERYSQL statementsSELECT * FROM users
NATIONALITYNationalitiesIndian, American
BANK_ACCOUNT_NUMBERBank account numbers123456789012
OCCUPATIONOccupations or job titlesSoftware Engineer
HASHHash valuesa1b2c3d4e5f6g7h8i9j0
OFFENSE_FILTERLegal offensesTheft, Fraud
GST_NUMBERGoods and Services Tax ID (India)22AAAAA0000A1Z5
CITATIONLegal or scholarly citationsDoe, J., 2024
COPYRIGHTCopyright symbols© 2024 Hrida AI
TRADEMARKTrademark names, ®
CONTRACTContract-related phrasesNon-disclosure agreement
POSTAL_CODEPostal or ZIP codes10001
SSN_NUMBERSocial Security numbers (USA)123-45-6789
VOTER_IDVoter identification numbersAB1234567
SOCIAL_MEDIA_HANDLESocial media usernames@john_doe
CVV_NUMBERCredit card CVV codes123
GENDER_PRONOUNGender pronounsHe, She, They
EMOJIEmoji characters😊, 🚀
IBAN_NUMBERInternational Bank Account NumbersGB33BUKB20201555555555
CRYPTO_ADDRESSCryptocurrency wallet addresses1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
UUIDUniversally Unique Identifiers123e4567-e89b-12d3-a456-426614174000
GEO_COORDINATESGeographic latitude and longitude37.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.