Giter VIP home page Giter VIP logo

node-file-encrypt's Introduction

node-file-encrypt

A file encrypt & decrypt package based on TEA

get & use

  1. get it

    git clone [email protected]:fiefdx/node-file-encrypt.git
    
    or
    
    npm install node-file-encrypt
    
  2. use it

    import fs from 'fs';
    
    import { FileEncrypt } from 'node-file-encrypt';
    
    let filePath = '/home/breeze/Develop/fast2array.tar'; // source file path
    let encryptPath = '';
    
    {   // encrypt file
        // to FileEncrypt can be passed 4 Arguments
        // filePath     - the path of the file that should be encrypted
        // outPath      - this is optional  - the Path for the encrypted file
        // fileEnding   - this is optional  - a custom fileEnding like '.myFile', default is '.crypt'
        // cryptFileName - this is optional - boolean if the filename should be hashed, default is true
        let f = new FileEncrypt(filePath);
        f.openSourceFile();
        f.encrypt('111111');
        encryptPath = f.encryptFilePath;
        console.log("encrypt sync done");
    }
    
    { // decrypt file
        fs.unlink(filePath, function() {});
        let f = new FileEncrypt(encryptPath);
        f.openSourceFile();
        f.decrypt('111111');
        console.log("decrypt sync done");
    }
    
    { // get original file name from encrypted file
        let f = new FileEncrypt(encryptPath);
        f.openSourceFile();
        console.log(f.info('111111'));
    }
    
    { // encrypt & decrypt file async
        let f = new FileEncrypt(filePath);
        f.openSourceFile();
        f.encryptAsync('111111').then(function() {
            encryptPath = f.encryptFilePath;
            console.log("encrypt async done");
            fs.unlink(filePath, function() {});
            let d = new FileEncrypt(encryptPath);
            d.openSourceFile();
            d.decryptAsync('111111').then(function() {
                console.log("decrypt async done");
            });
        });
    }
    $ sudo npm install -g node-file-encrypt
    $ crypt -h
    Usage: crypt [OPTION]...
    
     Options:
     -e : encrypt input file
     -d : decrypt input file
     -p : password
     -i : input file path (include file name)
     -o : output file path (exclude file name)
     -h : get this help

node-file-encrypt's People

Contributors

fiefdx avatar tobias-keller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node-file-encrypt's Issues

Buffer security issue

Hi fiefdx
in file_encrypt.js Buffers need to be replace => Buffer() is deprecated due to security and usability issues. Should use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead
But idk which method works

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.