1.0.1 • Published 7 years ago

client-encrypt-file-upload v1.0.1

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

client-encrypt-file-upload

A client side file encryptor for Node.js.

Installation

Add it to your node.js project via:

npm install client-encrypt-file-upload --save

Usage

As this is a client side script you'll need to compile this module and it's dependencies using browserify or something similar

browserify node_modules/client-encrypt-file-upload/dist/index.js  -o bundle.js

To encrypt a file upload:

    //Add change event to file upload field
    document.addEventListener('DOMContentLoaded',function() {
        document.querySelector('input[name="input_4"]').onchange=changeEventHandler;
    },false);

    //Handle the change event and call encryptFile
    //Encrypt file blob with secret key bla-bla-bla-bla-bla and return encrypted response data
    //via callback E.G {type: 'encrypted-string', data: 'iihkwqhury8473y4r3y3443yr3'} 
    function changeEventHandler(event) {
        encryptFile(event.target.files[0], 'bla-bla-bla-bla-bla', function(response){
          console.log(response.type);
          console.log(response.data);
        });
    }