Download the PHP package mastercard/client-encryption without Composer

On this page you can find all versions of the php package mastercard/client-encryption. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package client-encryption

client-encryption-php

maintenance-status

Table of Contents

Overview

Library for Mastercard API compliant payload encryption/decryption.

Compatibility

PHP 7.0+

References

Encryption of sensitive data

Versioning and Deprecation Policy

Usage

Prerequisites

Before using this library, you will need to set up a project in the Mastercard Developers Portal.

As part of this set up, you'll receive:

Adding the Library to Your Project

Loading the Encryption Certificate

A certificate resource can be created from a file by calling EncryptionUtils::loadEncryptionCertificate:

Supported certificate formats: PEM, DER.

Loading the Decryption Key

From a PKCS#12 Key Store

A private key resource can be created from a PKCS#12 key store by calling EncryptionUtils::loadDecryptionKey the following way:

From an Unencrypted Key File

A private key resource can be created from an unencrypted key file by calling EncryptionUtils::loadDecryptionKey the following way:

Supported RSA key formats:

Performing Field Level Encryption and Decryption

Introduction

The core methods responsible for payload encryption and decryption are encryptPayload and decryptPayload in the FieldLevelEncryption class.

Configuring the Field Level Encryption

Use the FieldLevelEncryptionConfigBuilder to create FieldLevelEncryptionConfig instances. Example:

See also:

Performing Encryption

Call FieldLevelEncryption::encryptPayload with a JSON request payload and a FieldLevelEncryptionConfig instance.

Example using the configuration above:

Output:

Performing Decryption

Call FieldLevelEncryption::decryptPayload with a JSON response payload and a FieldLevelEncryptionConfig instance.

Example using the configuration above:

Output:

Encrypting Entire Payloads

Entire payloads can be encrypted using the '$' operator as encryption path:

Example:

Output:

Decrypting Entire Payloads

Entire payloads can be decrypted using the '$' operator as decryption path:

Example:

Output:

Using HTTP Headers for Encryption Params

In the sections above, encryption parameters (initialization vector, encrypted symmetric key, etc.) are part of the HTTP payloads.

Here is how to configure the library for using HTTP headers instead.

Configuration for Using HTTP Headers

Call with{Param}HeaderName instead of with{Param}FieldName when building a FieldLevelEncryptionConfig instance. Example:

See also:

Encrypting Using HTTP Headers

Encryption can be performed using the following steps:

  1. Generate parameters by calling FieldLevelEncryptionParams::generate:

  2. Update the request headers:

  3. Call encryptPayload with params:

Example using the configuration above:

Output:

Decrypting Using HTTP Headers

Decryption can be performed using the following steps:

  1. Read the response headers:

  2. Create a FieldLevelEncryptionParams instance:

  3. Call decryptPayload with params:

Example using the configuration above:

Output:

Performing JWE Encryption and Decryption

Introduction

The core methods responsible for payload encryption and decryption are encryptPayload and decryptPayload in the JweEncryption class.

Configuring the JWE Encryption

Use the JweEncryptionConfigBuilder to create JweEncryptionConfig instances. Example:

Note: If withEncryptedValueFieldName is left blank, the value will default to encryptedData

See also:

Performing Encryption

Call JweEncryption::encryptPayload with a JSON request payload and a JweEncryptionConfig instance.

Example using the configuration above:

Output:

Performing Decryption

Call JweEncryption::decryptPayload with a JSON response payload and a JweEncryptionConfig instance.

Example using the configuration above:

Output:

Encrypting Entire Payloads

Entire payloads can be encrypted using the '$' operator as encryption path:

Example:

Output:

Decrypting Entire Payloads

Entire payloads can be decrypted using the '$' operator as decryption path:

Example:

Output:

Integrating with OpenAPI Generator API Client Libraries

OpenAPI Generator generates API client libraries from OpenAPI Specs. It provides generators and library templates for supporting multiple languages and frameworks.

This project provides you with some interceptor classes you can use when configuring your API client. These classes will take care of encrypting request and decrypting response payloads, but also of updating HTTP headers when needed.

Generators currently supported:

php

OpenAPI Generator

Client libraries can be generated using the following command:

See also:

Usage of the PsrHttpMessageEncryptionInterceptor for Field Level Encryption
Usage of the PsrHttpMessageEncryptionInterceptor for JWE Encryption

All versions of client-encryption with dependencies

PHP Build Version
Package Version
Requires phpseclib/phpseclib Version ~3.0
symfony/polyfill-php70 Version ^1.19
galbar/jsonpath Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mastercard/client-encryption contains the following files

Loading the files please wait ....