---
title: Asymmetric Encryption - Studio APIs
slug: api-portal/asymmetric-encryption-studio-apis
createdAt: 2025-03-11T07:04:48.155Z
---

# Asymmetric Encryption for Studio APIs

Signzy Studio APIs support **RSA-OAEP-256 (RSA 2048, SHA-256)** encryption for secure data transmission. You can encrypt any API request in just three steps.

## Step 1: Choose the API you want to encrypt

Navigate to the API you require on **“My APIs”** page on the [Signzy API Portal](https://portal.signzy.app) and click **Open API Studio**.

![API Catalog](https://api.archbee.com/api/optimize/w0YdjmC6Uxu0AJ6sPj9OT/yNUQ0vhK5CU-2KUu8mlb1_fireshot-capture-084-signzy-s-api-portal-portalsignzyapp.png "API Catalog")

## Step 2: Choose Asymmetric Encryption

![Select “Asymmetric Encryption” to proceed.](https://api.archbee.com/api/optimize/w0YdjmC6Uxu0AJ6sPj9OT/qQczS2MATKNIULf8tdWUk_fireshot-capture-077-signzy-s-api-portal-portalsignzyapp.png "Select “Asymmetric Encryption” to proceed.")

You can click here to download Signzy's Public Key anytime.

## Step 3: Encrypt your API Request

![Upload the PEM file and click Encrypt API to generate your curl request and response.](https://api.archbee.com/api/optimize/w0YdjmC6Uxu0AJ6sPj9OT/c9SIq3qI7W_qSruGokTHG_fireshot-capture-086-signzy-s-api-portal-portalsignzyapp.png "Upload the PEM file and click Encrypt API to generate your curl request and response.")

Ensure that the encryption key you upload is a **valid PKCS#8 (RSA 2048, SHA-256) .pem file**.

You can download this key from **My APIs&#x20;**&#x70;age in Signzy’s API portal.

Once you click on encrypt API, our systems will generate an encrypted version for the same API which accepts exactly the same input body and produces exactly the same output data but in an encrypted format.

The new input and output is wrapped in an object as shown below, the new API will accept the encrypted input as a string and produce the encrypted output as a string as well.



![Your encrypted curl request and response.](https://api.archbee.com/api/optimize/w0YdjmC6Uxu0AJ6sPj9OT/YLMK3-LXHYI3Vo53k_EQ7_fireshot-capture-087-signzy-s-api-portal-portalsignzyapp.png "Your encrypted curl request and response.")

### Sample Asymmetric Encrypted Curl

```js
curl -X POST https://api-preproduction.signzy.app/api/v3/studio/<YOUR-STUDIO-ID>/<YOUR-API> \
      -H 'Authorization:<your-signzy-auth-key>' \
      -H 'Content-type:application/json' \ 
      -d '{ "encryptedData":"<Your RS256 encrypted request string using Signzy's Public Key>" }'
```

### JSON Response

Response from from Signzy's Encrypted PAN Fetch - V3 API

```json
  {
      "encryptedData":"<RS256 encrypted response using your Public Key>"
    }
```

### Encryption Script

:::CodeblockTabs
```java
// Decryption using Nimbus JOSE + JWT library
// Add the following dependency in your Maven/Gradle project:
// Maven: <dependency> <groupId>com.nimbusds</groupId> <artifactId>nimbus-jose-jwt</artifactId> <version>9.31</version> </dependency>
// Gradle: implementation 'com.nimbusds:nimbus-jose-jwt:9.31'

package com.example;

import com.nimbusds.jose.*;
import com.nimbusds.jose.crypto.*;
import com.nimbusds.jose.jwk.*;

import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;

public class Main {

    public static String encrypt(String payload, String publicKeyPem) throws Exception {
        // Remove the "BEGIN" and "END" lines and decode the PEM public key
        String publicKeyPEM = publicKeyPem.replace("-----BEGIN PUBLIC KEY-----", "")
                .replace("-----END PUBLIC KEY-----", "")
                .replaceAll("\\s", "");

        byte[] decoded = Base64.getDecoder().decode(publicKeyPEM);
        X509EncodedKeySpec keySpec = new X509EncodedKeySpec(decoded);
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        PublicKey publicKey = keyFactory.generatePublic(keySpec);

        // Create RSAKey instance from the public key
        RSAKey rsaKey = new RSAKey.Builder((RSAPublicKey) publicKey).build();

        // Create the JWE object
        JWEObject jweObject = new JWEObject(
                new JWEHeader.Builder(JWEAlgorithm.RSA_OAEP_256, EncryptionMethod.A256GCM).build(),
                new Payload(payload));

        // Encrypt the JWE using the RSAKey
        jweObject.encrypt(new RSAEncrypter(rsaKey));

        // Serialize to compact form
        return jweObject.serialize();
    }

    public static void main(String[] args) throws Exception {
        String publicKeyPem = "<SIGNZY'S-PUBLIC-KEY-IN-PEM-FORMAT>";
        String payload = "{\"input\":\"sample\"}";
        String encrypted = encrypt(payload, publicKeyPem);
        System.out.println("Encrypted: " + encrypted);
    }
}
```

```javascript
const jose = require("jose");

const publicKeyPem = "<SIGNZY'S-PUBLIC-KEY-IN-PEM-FORMAT>";

async function encrypt(payload) {
  const publicKey = await jose.importSPKI(publicKeyPem, "RS256");
  const jwe = await new jose.CompactEncrypt(
    new TextEncoder().encode(JSON.stringify(payload))
  )
    .setProtectedHeader({ alg: "RSA-OAEP-256", enc: "A256GCM" })
    .encrypt(publicKey);

  return jwe;
}

// Example usage
const jose = require("jose");

const publicKeyPem = "<SIGNZY'S-PUBLIC-KEY-IN-PEM-FORMAT>";

async function encrypt(payload) {
  const publicKey = await jose.importSPKI(publicKeyPem, "RS256");
  const jwe = await new jose.CompactEncrypt(
    new TextEncoder().encode(JSON.stringify(payload))
  )
    .setProtectedHeader({ alg: "RSA-OAEP-256", enc: "A256GCM" })
    .encrypt(publicKey);

  return jwe;
}

// Example usage
const encrypted = await encrypt('{"input":"sample"}');
console.log(encrypted);
```
:::

### Decryption script

:::CodeblockTabs
```java
// Decryption using Nimbus JOSE + JWT library
// Add the following dependency in your Maven/Gradle project:
// Maven: <dependency> <groupId>com.nimbusds</groupId> <artifactId>nimbus-jose-jwt</artifactId> <version>9.31</version> </dependency>
// Gradle: implementation 'com.nimbusds:nimbus-jose-jwt:9.31'

package com.example;

import com.nimbusds.jose.*;
import com.nimbusds.jose.crypto.*;

import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Base64;

public class Main {

    public static String decrypt(String encryptedJWResponse, String privateKeyPem) throws Exception {
        // Remove the "BEGIN" and "END" lines and decode the PEM private key
        String privateKeyPEM = privateKeyPem.replace("-----BEGIN PRIVATE KEY-----", "")
                .replace("-----END PRIVATE KEY-----", "")
                .replaceAll("\\s", "");

        byte[] decoded = Base64.getDecoder().decode(privateKeyPEM);
        PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(decoded);
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        PrivateKey privateKey = keyFactory.generatePrivate(keySpec);

        // Parse the JWE
        JWEObject jweObject = JWEObject.parse(encryptedJWResponse);
        RSADecrypter decrypter = new RSADecrypter(privateKey);
        jweObject.decrypt(decrypter);

        // Get the decrypted payload
        return jweObject.getPayload().toString();
    }

    public static void main(String[] args) throws Exception {
        String privateKeyPem = "<YOUR-PRIVATE-KEY-IN-PEM-FORMAT>";
        String decrypted = decrypt(
                "<YOUR-ENCRYPTED-RESPONSE-BODY>",
                privateKeyPem);
        System.out.println("Decrypted: " + decrypted);
    }
}
```

```javascript
const jose = require("jose");

const privateKeyPem = '<YOUR-PRIVATE-KEY-IN-PEM-FORMAT>';

async function decrypt(encryptedJWResponse) {
  const privateKey = await jose.importPKCS8(privateKeyPem, "RS256");
  const decrypted = await jose.compactDecrypt(encryptedJWResponse, privateKey);
  return new TextDecoder().decode(decrypted.plaintext);
}

// Example usage
const encryptedMessage = '<YOUR-ENCRYPTED-RESPONSE-BODY>'
const encrypted = await decrypt(encryptedMessage);
console.log(encrypted);
```
:::

