ParryGroup Encryption API

FREEMIUM
Par BeamWaresLtd | Mise à jour 2 месяца назад | Cryptography
Health Check

N/A

Retour à tous les tutoriels (1)

API Tutorial

Example

Supposedly, a corporation has a feeds section within an admin portal. And within this portal, sensitive information is being exchanged by employees and these data are only expected to appear within this portal. This portal needs a way to safeguard their data to avoid exposure if there is any leak within their database.
To execute such solutions, the portal may need to encrypt every post/update that is being rendered on the portal feeds. While decrypting such data when being rendered on the portal.

• Encryption:

Lets say any post or update by an employee is equipped with such JSON data schema:

{
Name: “John Doe”,
Body:
Date: 20, 09, 2024
}

In order to upload such post, the body of the data needs to be encrypted before being pushed into the database.
We can now use the “Get encrypted response of alphanumeric characters” POST request to send the body of the post and get a response of a JSON object containing the encrypted body.

Code snippet:

  **var post = {
    Name: "John Doe",
    Body: "Lorem ipsum dolor sit, amet consectetur adipisicing elit.",
    Date: "20, 09, 2024",
}

fetch(`/*encryption endpoint*/enc`, { 
    method: 'post', 
    body: JSON.stringify({ text: post.Body }), 
    headers: { "Content-type" : "application/json; charset=utf-8" } }).then((response) => {
    return response.json();
}).then((data) => {
    if (data) {
        post = {
            Name: "John Doe",
            Body: data,
            Date: "20, 09, 2024",
        }
        // You can nonw upload such data into your database
        pushToDb(post);
    }
});**

After that you can now submit the post your database.

• Decryption

When employees login to the portal, every post needs to be decrypted In order to display the original text.
This process is similar and as simple as the encryption procedure. Posts needs to be extracted and passed to a decryption function which can now send the “Get decrypted response of alphanumeric characters initially encrypted” POST request to decrypt the body and send its original format.

Code snippet:

	**// After extraction
var post = {
    Name: "John Doe",
    // encrypted text/body
    Body: {k: "*", m: '*'},
    Date: "20, 09, 2024",
}
decrypt(post)

const decrypt = (data) => {
    fetch(`/*encryption endpoint*/dcr`, { 
		 method: 'post', 
	   body: JSON.stringify({ object: data.body }), 
			headers: { "Content-type" : "application/json; charset=utf-8" } }).then((response) => {
        return response.json();
    }).then((body) => {
        if (body) {
            post = {
                Name: "John Doe",
                Body: body, // Lorem ipsum dolor sit, amet consectetur adipisicing elit.
                Date: "20, 09, 2024",
            }
            // you can now display the posts with its original text
            display(post);
        }
    });
}**
	
	You can now display the post with its decrypted/original value