Giter Club home page Giter Club logo

btfs-encryption's Introduction

BTFS-Encryption

btfs-encryption is a demo project for BTFS Encrypted Storage Protocol, and provide a binary you can use to encrypt/decrypt files from/to btfs with this protocol:

How to install

  • Use go tools
    go install github.com/bittorrent/btfs-encryption/cmd/btfs-encryption@latest
  • Build from source: if you have installed go and make tools, you can clone the source code and make:
    git clone [email protected]:bittorrent/btfs-encryption.git && cd btfs-encryption && make
    the binary will be build as btfs-encryption in the current directory.

Prerequisites

  • This project use RSA algorithm to encrypt the secret, so before use the binary, enable the RSA public/private key pairs has been generated in the local. These key pairs can be generated by below commands:
    ssh-keygen -t rsa
    Or you can just use the exists key pairs, they are commonly be $HOME/.ssh/id_rsa and $HOME/.ssh/id_rsa.pub.
  • If you need add encrypted file to BTFS and decrypted file from BTFS, before use these commands, you need set the BTFS_HOST environment variable.
    export BTFS_HOST=<btfs_api_host>

Commands

NAME:
   btfs-encryption - btfs-encryption is a demo project for btfs encryption protocol

USAGE:
   btfs-encryption [global options] command [command options] [arguments...]

VERSION:
   v0.1.0

COMMANDS:
   encrypt        Encrypt local file or folder and add it to BTFS
   decrypt        Get encrypted file from BTFS and decrypt it to local
   encrypt-local  Encrypt local file or folder
   decrypt-local  Decrypt local encrypted file
   help, h        Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help (default: false)
   --version, -v  print the version (default: false)
  • Encrypt local file or folder and add it to BTFS

    ./btfs-encryption encrypt [-pub <public_key_path>] <source_file_or_folder_path>

    If it works, the output will show the encrypted BTFS file info:

    Encrypted File: 
    CID  - <CID>
    Name - <Name>
    Size - <Size>
  • Get encrypted file from BTFS and decrypt it to local

    ./btfs-encryption decrypt [-dst <destination_directory_path>] [-prv <private_key_path>] <cid>

    If it works, the decrypted files will be in the specified destination directory, and output will be:

    completed!
  • Encrypt local file or folder

    ./btfs-encryption encrypt-local [-dst <destination_directory_path>] [-pub <public_key_path>] <source_file_or_folder_path>

    If it works, the encrypted file will be in the specified destination directory, and output will be:

    completed!
  • Decrypt local encrypted file

    ./btfs-encryption decrypt-local [-src <source_file_path>] [-dst <destination_directory_path>] [-prv <private_key_path>] <cid>

    If it works, the decrypted files will be in the specified destination directory, and output will be:

    completed!

Used as library

The project can be used as library for convenience:

go get github.com/bittorrent/btfs-encryption 
package main

import (
    "github.com/bittorrent/btfs-encryption/enc"
)

func main() {
    // encryption
    err := enc.EncryptToLocal("path/to/source", "path/to/dest", "path/to/public/key")
    if err != nil {
        return 
    }
    
    // decryption
    err = enc.DecryptFromLocal("path/to/source", "path/to/dest", "path/to/private/key")
    if err != nil {
        return
    }
}

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.