# How to encrypt and decrypt payloads source: https://developer.mastercard.com/donations/tutorial/how-to-access-sandbox-environment/mastercard-encryption-decryption-mechanism/index.md ## How to encrypt and decrypt payloads {#how-to-encrypt-and-decrypt-payloads} After you have all the required consumer credentials, API payload, and parameters, you will need to encrypt the API request payload and decrypt the API response payload. Note: Some Donate APIs accept encrypted request payload and respond back with encrypted response payload. For more details on each API, refer to the [Parameters](https://developer.mastercard.com/donations/documentation/parameters/index.md) section. * Before calling Donate APIs, read this [documentation](https://developer.mastercard.com/platform/documentation/security-and-authentication/securing-sensitive-data-using-payload-encryption) to understand how to secure sensitive data using payload encryption. * You must encrypt your request payload using the [Mastercard provided Client Encryption library](https://github.com/Mastercard/client-encryption-java#encrypting-entire-payloads-) if you are using this library in your Java application. * Build your request payload and encrypt it using the provided library within your Java application, typically hosted on your server or cloud. * Call the APIs. If you are calling the APIs without a server-side application, you must manually encrypt the request payload before sending it. * To decrypt the full API response payload within your server-side Java application, refer to the relevant [page](https://github.com/Mastercard/client-encryption-java#decrypting-entire-payloads-) in Mastercard's Client Encryption library documentation. * For encrypting and decrypting payloads in languages other than Java, use [Mastercard provided Client Encryption libraries](https://developer.mastercard.com/platform/documentation/security-and-authentication/securing-sensitive-data-using-payload-encryption/) Tip: It is strongly recommended to use existing Mastercard provided client encryption libraries rather than implementing the encryption and decryption steps yourself.