# Enable encryption
source: https://developer.mastercard.com/mastercard-checkout-solutions/tutorial/use-postman-for-mastercard-checkout-services-apis/step5/index.md

## Enable encryption {#enable-encryption}

Note: Not all Mastercard services use encryption. If the service you are trying to call doesn't use encryption, this step can be skipped.

Mastercard supports 2 different types of encryption, Mastercard encryption and JWE encryption. The type of encryption may differ from service to service.
If you imported an Open API specification in [Step 1](https://developer.mastercard.com/mastercard-checkout-solutions/tutorial/use-postman-for-mastercard-checkout-services-apis/step1/index.md) instead of forking from the Mastercard workspace, then do the following:

1. Click on your collection, navigate to **Scripts** tab \> `Pre-request` section and paste the following code:

* Js

```js
  const { v4: uuidv4 } = require('uuid');
  const nonce = uuidv4();
  var timestamp = (new Date().getTime() / 1000).toFixed(0);
  pm.environment.set("nonce", nonce);
  pm.environment.set("timestamp", timestamp);
  // Fetch the Mastercard encryption library and store it in the environment.
  if(!pm.environment.get("encryptionScript")){
      pm.sendRequest("https://github.com/Mastercard/postman-encryption-lib/releases/latest/download/mastercard-postman-encryption-lib.min.js", function (err, response) {
          if (err) {
              console.log(`Error downloading script: ${err}`);
              return;
          }
          pm.environment.set("encryptionScript", response.text());
          console.log("Encryption script downloaded")
      })
  }
  
```

2. Next, click on the request/API endpoint that needs encryption, navigate to **Scripts** tab \> `Pre-request` section and paste the following code:

* Js

```js
eval(pm.environment.get("encryptionScript"));
encryptRequest(pm.environment.get("encryptionType"), pm);
```

**JK: the following sections have to be validated and confirmed with Kapil and Neha. The edits will follow.**

Depending on the type of encryption used by the service you wish to call, choose the relevant set of instructions below.
