Skip to main content

Step 3: Encrypt Address and Location Data

In addition to customer and payment PII, location data like street addresses and detailed zip codes must also be protected. In this step, you will extend your pipeline to encrypt address information while preserving city, state, and a partial zip code for regional analytics.

The Goal​

You will enhance your processor to handle the billing_address object by:

  1. Encrypting the street and zip fields.
  2. Creating a zip_prefix field containing the first 3 digits of the zip for safe regional analysis.
  3. Deleting the original street and zip fields.

Implementation​

  1. Start with the Previous Pipeline: Copy the encrypt-pii.yaml file from Step 2 to a new file named encrypt-location.yaml.

    cp encrypt-pii.yaml encrypt-location.yaml
  2. Inspect the maintained mapping: Review the selected fields, key lookup, and plaintext removal in the linked reference before adapting the processor.

    See the complete configuration for the maintained encryption mapping and its ciphertext fields.

    Note: Use the key variable names from the configuration you are adapting.

  3. Deploy and Test:

    # Send the sample payment data, which includes an address
    curl -X POST http://localhost:8080/events/payment \
    -H "Content-Type: application/json" \
    -d @/tmp/encryption-test/sample-payment.json
  4. Verify: Check your logs. You will see that the billing_address object now contains street_encrypted, zip_encrypted, and the safe zip_prefix, while the original sensitive fields are gone. All the previous PII (card number, SSN, etc.) is still being encrypted correctly.

You have now built a comprehensive PII protection pipeline that covers payment, personal, and location data.