Step 1: Encrypt Credit Card Data
This step selects the synthetic card number for encryption while retaining authored display fields such as the last four digits and brand. Review those retained values independently before adapting the pattern.
The Goal
You will transform the payment object by:
- Encrypting the
card_numberinto a newcard_number_encryptedfield. - Extracting the
card_last_fourandcard_brandfor analytics. - Deleting the original, plaintext
card_number.
Input Snippet:
{
"payment": {
"card_number": "4532-1234-5678-9010",
"expiration": "12/27"
}
}
Desired Output Snippet:
{
"payment": {
"expiration": "12/27",
"card_number_encrypted": "AES256GCM:v1:...",
"card_last_four": "9010",
"card_brand": "visa"
}
}
Implementation
-
Start with the Foundation: Copy
encryption-foundation.yamlto a new file,encrypt-card.yaml.cp examples/data-security/encryption-foundation.yaml encrypt-card.yaml -
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.
-
Deploy and Test:
# Send the sample payment data from the setup step
curl -X POST http://localhost:8080/events/payment \
-H "Content-Type: application/json" \
-d @/tmp/encryption-test/sample-payment.json -
Verify: Check your logs. You will see that the
card_numberfield is gone, replaced bycard_number_encrypted,card_last_four, andcard_brand.
The reference now shows the payment-field selection pattern. It has not been executed or assessed against a deployed threat model.