1. Home
  2. ...
  3. Other Information
  4. API Crypto

API Crypto

API maintained by Sensedia for encryption operations β€” digest, keys, sign and verify.

API Crypto is an API maintained by Sensedia and which is pre-registered on the API Manager. You can use it to perform encryption operations. These operations can be used on other interceptors' flow, such as Digital Signature and Encrypt.

This page shows examples on how to use each API resource.

Digest

This resource generates a digest from an algorithm, data, and a salt. As of now, the algorithm available for the hash function is PBKDF2-HMAC-SHA1.

This is an example of using this resource with the required payload, and after that a code block of a payload with all possible attributes for the hash function.

TIP

Salts are important to avoid dictionary attacks, since they are concatenated with the data before being processed by the hash function, adding randomness to the digest generated.

Example of digest generated from a given piece of data using a PBKDF2-HMAC-SHA1 function:

Request

Headers

Name
Description
Content-TypeShould be application/json
AuthorizationBasic client_id:client_secret (Base64)
CAUTION

All endpoints of this API are protected with the Client Id Secret Encoded Validation interceptor. Thus, all requests must contain the Authorization header described above.

Request body

There are optional attributes in the body that, when not informed, assume the default value of:

NOTE

The attribute saltType treats the reported salt type and can assume HEX (Hexadecimal) or ASCII (String) values.

digestType treats the returned digest type and can assume HEX (Hexadecimal) or Base64 values.

Response Body

The response will bring its digest with fixed size, according to the hash algorithm used.

Keys

The resource keys generates pairs of public-private keys. These keys are essential if you are using the Digital Signature interceptor, but the resource works regardless of interceptors. That is, you can use it to generate keys for the most diverse contexts.

The resource has the following methods and endpoints:

The method above generates a pair of keys. As a requirement, it needs a payload containing what type of algorithm will be used to generate the keys.

Example generating RSA keys:

Once the request is done, a pair of keys will be contained in the response:

NOTE

As of now, the types supported are RSA and AES.

In addition to the endpoint described above, there is also an endpoint exclusively for the obtention of a public key:

It's easy to use this endpoint. A GET request will return an RSA public key, as in the example below:

Sign

This resource signs a key. A use case for the Platform is described on the Digital Signature interceptor's flow.

The backend expects a payload with the following properties:

Once the request is done, the signature will be in the response body.

TIP

As described above, more examples on how to use the resources sign and keys on the Platform can be found on the page regarding the Digital Signature interceptor.

Verify

The resource verify has only one endpoint, which validates key and signature.

The request must contain a JSON with some required properties:

The response will contain only one property, indicating whether key and signature are valid.

Swagger

There is a Swagger file for API Crypto. You can see it to check the DTOs (Data Transfer Objects) used for each endpoint, which helps to understand the payloads and the way each resource works. This is the URI to access the Swagger interface:

Examples on using the encryption generated by the API Crypto module

For more examples regarding using API Crypto, check the pages on the interceptors Digital Signature and Encrypt.

How happy are you with this page?

We use cookies to enhance your experience on our site. By continuing to browse, you agree to our use of cookies.Learn more