Socket
Book a DemoInstallSign in
Socket

encryption-services

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

encryption-services

This library provides an interface for encrypting and decrypting messages using Zenroom's cryptographic engine, with public key sharing and key generation features. It simplifies the process of establishing secure communication between clients and servers

unpublished
latest
Source
npmnpm
Version
1.0.6
Version published
Maintainers
0
Created
Source

Zenroom Encryption Service

This library provides an interface for encrypting and decrypting messages using Zenroom's cryptographic engine, with public key sharing and key generation features. It simplifies the process of establishing secure communication between clients and servers.

Installation

To install the library, use npm or yarn:

npm install encryption-services

or

yarn add encryption-services

Usage

Importing the Library

import { EncryptionService } from 'encryption-services';

Initialize the App

To initialize the encryption service, you need to provide the server's public key URL and a shared key URL:

const services = new EncryptionService();
services.initialize('https://server.com/public-key', 'https://server.com/shared-key').subscribe((data) => {
    setClientId(data.clientID)
    setIsReady(data.isReady)
    setServerPubKey(data.serverPublicKey)
    setPrivateKey(data.privateKey)
});

The initialize Method Returns:

  • clientID: A randomly generated client ID used to uniquely identify the client in communication with the server.
  • isReady: A boolean value indicating whether the encryption service is ready to send and receive encrypted messages.
  • serverPublicKey: The server's public key, which is used to encrypt messages sent to the server.
  • privateKey: The client's private key, which is used to decrypt messages received from the server.

Once the initialization process is complete, these values can be used in the rest of the encryption and decryption processes.

Encrypting Messages

To encrypt a message, call the encryptMessage method after the service is ready. Ensure that you pass the message, server public key, and the client's private key:

function encryptMessage(message) {
    return new Promise((resolve, reject) => {
        services.encryptMessage(message, serverPubKey, privateKey).subscribe(
            (result) => {
                resolve(result);
            },
            (error) => {
                reject(error);
            }
        );
    });
}

Decrypting Messages

To decrypt a message received from the server, use the decryptMessage method:

function decryptResponse(message) {
    return new Promise((resolve, reject) => {
        services.decryptMessage(message, serverPubKey, privateKey).subscribe(
            (result) => {
                resolve(result);
            },
            (error) => {
                reject(error);
            }
        );
    });
}

Keywords

encryption

FAQs

Package last updated on 11 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.