Welcome to our new developer portal! Use the "Ask" button to chat with our AI Agent.
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Encrypt sensitive data

To exchange sensitive information, the D1 Transit backend expects to receive (or send) sensitive data encrypted using the standard JWE format (https://datatracker.ietf.org/doc/html/rfc7516 ).

Sensitive information is encoded in JSON format prior encryption.

D1 Transit backend uses the following configuration for JWE:

  • JWE base64url encoded string

  • "alg" (Algorithm) header parameter: ECDH-ES

  • "enc" (Encryption Algorithm) header parameter: A256GCM

  • "kid" (Key ID) header parameter: Key identifier corresponding to EC public key of the recipient

  • EC curve: P-256

Examples of Sensitive Data Encryption

In this section you can find few examples of a JWE object encryption.

Example: To encrypt card credentials with following parameters:

JSON field parameter name
description
MOC
Length

pan

The Primary Account Number

M

Up to 19

exp

The expiry date in the format MMYY

M

4

EC public key:

{
    "kty": "EC",
    "kid": "ASDsL-Jx2XOkRnFtqW-QblWY-mDnQW2LgapadFx75tA",
    "crv": "P-256",
    "x": "UbInEqNbZZZ9SJptBwKTKO6qslSyuWvMkVK44Bx_d8U",
    "y": "PUxeHMNVL0VRxOYJrkHcpe6sap7IG-Are0QborZDngI",
}

Clear data:

Source code samples:

Examples of sensitive data decryption

In this section you can find few examples of a JWE object decryption.

Last updated

Was this helpful?