Code Monkey home page Code Monkey logo

demo-sharing-js's Introduction

Virgil Secure Sharing Demo

This is a demo app showing one way you can use Virgil Crypto Library in javascript to create a secure file sharing app. After you complete the steps in Setup section you will be able to download, decrypt and view encrypted media files from a browser.

Setup

Clone the repository

$ git clone https://github.com/VirgilSecurity/virgil-secure-sharing.git
$ cd ./secure-sharing

Install the dependencies

$ npm install

Configure

In order to decrypt files the app needs a private part of the key used to encrypt the files, private key password and recipient id used during encryption. Set these as environment variables before starting the server. For example, execute:

PRIVATE_KEY=<base64_encoded_private_key> PRIVATE_KEY_PASSWORD=<private_key_password> RECIPIENT_ID=<recipient_id> npm run start

to set variables and start a server on Unix platform.

Prepare encrypted files

Encrypt

To encrypt the files you can use Virgil CLI tool. Instructions on how to encrypt data without using Virgil Services can be found here.

Upload

Upload the files to some publicly available storage (e.g. Dropbox) so that they can be downloaded by the app.

Create metadata

In order for decrypted media files to be opened accordingly to their type you must provide MIME type of the file along with it's download url. You do that by creating a JSON object with two properties "type" and "url":

{
	"type": "video/mp4",
	"url": "https://example.com/encrypted_video"
}

Encode the metadata

The metadata are passed to the app via url query parameter named source. The value of that parameter should be a base64-encoded metadata JSON. There are multiple ways to encode a string in base64 any of which should work fine for this example.

Give it a try

Now open your browser and point to http://localhost:3000/?source=<source> where <source> is the string obtained on the previous step.

Notes

Supported MIME types

For audio and video files only the following MIME types are supported:

Audio

  • audio/aac (.aac)
  • audio/mp4 (.mp4 .m4a)
  • audio/mpeg (.mp1 .mp2 .mp3 .mpg .mpeg)
  • audio/ogg (.oga .ogg)
  • audio/wav (.wav)
  • audio/webm (.webm)

Video

  • video/mp4 (.mp4 .m4v)
  • video/ogg (.ogv)
  • video/webm (.webm)

File sizes

Due to the use of Blob objects the maximum file size is limited to 500Mb in Google Chrome browser. In browsers where size of Blob is not restricted it is not guaranteed that files over ~700Mb will be successfully decrypted due to memory limitations.

Live demo

demo-sharing-js's People

Contributors

vadimavdeev avatar unlim-it avatar davidszabo26 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.