Giter Site home page Giter Site logo

fgribreau / datapeps-sdk-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wallix/datapeps-sdk-js

0.0 1.0 0.0 2.91 MB

DataPeps SDK in TypeScript/JavaScript

Home Page: https://datapeps.com/docs/sdk/js/

License: Apache License 2.0

JavaScript 78.91% TypeScript 21.09%

datapeps-sdk-js's Introduction

DataPeps SDK

This repository contains the source for the DataPeps SDK for JavaScript (written in TypeScript), released under the Apache License.

DataPeps is an End-to-End Encryption platform. By integrating this SDK in your application, you can encrypt resources on clients (web, mobile, ...) to store and share data securely. For you, as a developer, one of the main benefits is that the cryptography implementation is foolproof and you don't need any knowledge of cryptography.

Getting started

The simplest way to get started is to add DataPeps SDK, using your favourite package manager.

With npm, go to your project directory and run:

npm install datapeps-sdk --save

If you prefer yarn, go to your project directory and run:

yarn add datapeps-sdk

Once installed, just add the following line to your code to import the DataPeps SDK:

import * as DataPeps from "datapeps-sdk";

If you plan to use DataPeps with Node.js (for testing with Mocha for instance), please read more about dependencies in the wiki.

Hello, DataPeps!

Say there are two friends, Alice and Bob. Alice wants to send a picture to Bob; however, Alice is quite rather concerned about data security (good for her!), and she wants to ensure, that only Bob can eventually read the picture. DataPeps to the rescue!

With DataPeps, Alice encrypts the message like this:

async function aliceSend() {
  let aliceSession = await DataPeps.Session.login(aliceLogin, alicePassword);
  let resource = await aliceSession.Resource.create("text", "", [bobLogin]);
  let messageToBob = "Hello, Bob!";
  let encryptedMessage = resource.encrypt(
    new TextEncoder().encode(messageToBob)
  );
  console.log('Alice sent a message: "' + messageToBob + '"');
  return [resource.id, encryptedMessage];
}

and Bob decrypts the message like this:

async function bobReceive(resourceId, encryptedMessage) {
  let bobSession = await DataPeps.Session.login(bobLogin, bobPassword);
  let resource = await bobSession.Resource.get(resourceId);
  let decryptedMessage = resource.decrypt(encryptedMessage);
  let messageToBob = new TextDecoder().decode(decryptedMessage);
  console.log('Bob received message: "' + messageToBob + '"');
}

If you want a detailed explanation of the code above, look it up in the wiki.

Want to try asap? Here is a complete Gist.

Learn more

DataPeps is written by the Innovation Department at WALLIX.

datapeps-sdk-js's People

Contributors

fxaguessy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.